<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><script type="text/javascript" src="https://cdn.jsdelivr.net/gh/opencobra/cobratoolbox@ffa0229fc0c01c9236bb7e961f65712443277719/latest/_static/js/iframeResizer.contentWindow.min.js"></script><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge,IE=9,chrome=1"><meta name="generator" content="MATLAB 2021a"><title>Model manipulation</title><style type="text/css">.rtcContent { padding: 30px; } .S0 { margin: 3px 10px 5px 4px; padding: 0px; line-height: 28.8px; min-height: 0px; white-space: normal; color: rgb(213, 80, 0); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 24px; font-weight: normal; text-align: left;  }
.S1 { margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: normal; color: rgb(0, 0, 0); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: normal; text-align: left;  }
.S2 { margin: 20px 10px 5px 4px; padding: 0px; line-height: 20px; min-height: 0px; white-space: normal; color: rgb(60, 60, 60); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 20px; font-weight: bold; text-align: left;  }
.S3 { margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: normal; color: rgb(0, 0, 0); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: normal; text-align: center;  }
.S4 { margin: 10px 0px 20px; padding-left: 0px; font-family: Helvetica, Arial, sans-serif; font-size: 14px;  }
.S5 { margin-left: 56px; line-height: 21px; min-height: 0px; text-align: left; white-space: normal;  }
.S6 { margin: 3px 10px 5px 4px; padding: 0px; line-height: 20px; min-height: 0px; white-space: normal; color: rgb(60, 60, 60); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 20px; font-weight: bold; text-align: left;  }
.CodeBlock { background-color: #F7F7F7; margin: 10px 0 10px 0;}
.S7 { border-left: 1px solid rgb(233, 233, 233); border-right: 1px solid rgb(233, 233, 233); border-top: 1px solid rgb(233, 233, 233); border-bottom: 1px solid rgb(233, 233, 233); border-radius: 4px 4px 0px 0px; padding: 6px 45px 4px 13px; line-height: 17.234px; min-height: 18px; white-space: nowrap; color: rgb(0, 0, 0); font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 14px;  }
.S8 { color: rgb(64, 64, 64); padding: 10px 0px 6px 17px; background: rgb(255, 255, 255) none repeat scroll 0% 0% / auto padding-box border-box; font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 14px; overflow-x: hidden; line-height: 17.234px;  }
/* Styling that is common to warnings and errors is in diagnosticOutput.css */.embeddedOutputsErrorElement {    min-height: 18px;    max-height: 250px;    overflow: auto;}
.embeddedOutputsErrorElement.inlineElement {}
.embeddedOutputsErrorElement.rightPaneElement {}
/* Styling that is common to warnings and errors is in diagnosticOutput.css */.embeddedOutputsWarningElement{    min-height: 18px;    max-height: 250px;    overflow: auto;}
.embeddedOutputsWarningElement.inlineElement {}
.embeddedOutputsWarningElement.rightPaneElement {}
/* Copyright 2015-2019 The MathWorks, Inc. *//* In this file, styles are not scoped to rtcContainer since they could be in the Dojo Tooltip */.diagnosticMessage-wrapper {    font-family: Menlo, Monaco, Consolas, "Courier New", monospace;    font-size: 12px;}
.diagnosticMessage-wrapper.diagnosticMessage-warningType {    color: rgb(255,100,0);}
.diagnosticMessage-wrapper.diagnosticMessage-warningType a {    color: rgb(255,100,0);    text-decoration: underline;}
.diagnosticMessage-wrapper.diagnosticMessage-errorType {    color: rgb(230,0,0);}
.diagnosticMessage-wrapper.diagnosticMessage-errorType a {    color: rgb(230,0,0);    text-decoration: underline;}
.diagnosticMessage-wrapper .diagnosticMessage-messagePart,.diagnosticMessage-wrapper .diagnosticMessage-causePart {    white-space: normal;}
.diagnosticMessage-wrapper .diagnosticMessage-stackPart {    white-space: normal;}
.embeddedOutputsTextElement,.embeddedOutputsVariableStringElement {    white-space: normal;    word-wrap:  initial;    min-height: 18px;    max-height: 250px;    overflow: auto;}
.textElement,.rtcDataTipElement .textElement {    padding-top: 3px;}
.embeddedOutputsTextElement.inlineElement,.embeddedOutputsVariableStringElement.inlineElement {}
.inlineElement .textElement {}
.embeddedOutputsTextElement.rightPaneElement,.embeddedOutputsVariableStringElement.rightPaneElement {    min-height: 16px;}
.rightPaneElement .textElement {    padding-top: 2px;    padding-left: 9px;}
.S9 { border-left: 1px solid rgb(233, 233, 233); border-right: 1px solid rgb(233, 233, 233); border-top: 1px solid rgb(233, 233, 233); border-bottom: 0px none rgb(0, 0, 0); border-radius: 4px 4px 0px 0px; padding: 6px 45px 0px 13px; line-height: 17.234px; min-height: 18px; white-space: nowrap; color: rgb(0, 0, 0); font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 14px;  }
.S10 { border-left: 1px solid rgb(233, 233, 233); border-right: 1px solid rgb(233, 233, 233); border-top: 0px none rgb(0, 0, 0); border-bottom: 0px none rgb(0, 0, 0); border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 17.234px; min-height: 18px; white-space: nowrap; color: rgb(0, 0, 0); font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 14px;  }
.S11 { border-left: 1px solid rgb(233, 233, 233); border-right: 1px solid rgb(233, 233, 233); border-top: 0px none rgb(0, 0, 0); border-bottom: 1px solid rgb(233, 233, 233); border-radius: 0px; padding: 0px 45px 4px 13px; line-height: 17.234px; min-height: 18px; white-space: nowrap; color: rgb(0, 0, 0); font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 14px;  }
.variableValue { width: 100% !important; }
.embeddedOutputsMatrixElement,.eoOutputWrapper .matrixElement {    min-height: 18px;    box-sizing: border-box;}
.embeddedOutputsMatrixElement .matrixElement,.eoOutputWrapper  .matrixElement,.rtcDataTipElement .matrixElement {    position: relative;}
.matrixElement .variableValue,.rtcDataTipElement .matrixElement .variableValue {    white-space: normal;    display: inline-block;    vertical-align: top;    overflow: hidden;}
.embeddedOutputsMatrixElement.inlineElement {}
.embeddedOutputsMatrixElement.inlineElement .topHeaderWrapper {    display: none;}
.embeddedOutputsMatrixElement.inlineElement .veTable .body {    padding-top: 0 !important;    max-height: 100px;}
.inlineElement .matrixElement {    max-height: 300px;}
.embeddedOutputsMatrixElement.rightPaneElement {}
.rightPaneElement .matrixElement,.rtcDataTipElement .matrixElement {    overflow: hidden;    padding-left: 9px;}
.rightPaneElement .matrixElement {    margin-bottom: -1px;}
.embeddedOutputsMatrixElement .matrixElement .valueContainer,.eoOutputWrapper .matrixElement .valueContainer,.rtcDataTipElement .matrixElement .valueContainer {    white-space: nowrap;    margin-bottom: 3px;}
.embeddedOutputsMatrixElement .matrixElement .valueContainer .horizontalEllipsis.hide,.embeddedOutputsMatrixElement .matrixElement .verticalEllipsis.hide,.eoOutputWrapper .matrixElement .valueContainer .horizontalEllipsis.hide,.eoOutputWrapper .matrixElement .verticalEllipsis.hide,.rtcDataTipElement .matrixElement .valueContainer .horizontalEllipsis.hide,.rtcDataTipElement .matrixElement .verticalEllipsis.hide {    display: none;}
.embeddedOutputsVariableMatrixElement .matrixElement .valueContainer.hideEllipses .verticalEllipsis, .embeddedOutputsVariableMatrixElement .matrixElement .valueContainer.hideEllipses .horizontalEllipsis {    display:none;}
.embeddedOutputsMatrixElement .matrixElement .valueContainer .horizontalEllipsis,.eoOutputWrapper .matrixElement .valueContainer .horizontalEllipsis {    margin-bottom: -3px;}
.eoOutputWrapper .embeddedOutputsVariableMatrixElement .matrixElement .valueContainer {    cursor: default !important;}
/* * Ellipses as base64 for HTML export. */.matrixElement .horizontalEllipsis,.rtcDataTipElement .matrixElement .horizontalEllipsis {    display: inline-block;    margin-top: 3px;    /* base64 encoded version of images-liveeditor/HEllipsis.png */    width: 30px;    height: 12px;    background-repeat: no-repeat;    background-image: url("");}
.matrixElement .verticalEllipsis,.textElement .verticalEllipsis,.rtcDataTipElement .matrixElement .verticalEllipsis,.rtcDataTipElement .textElement .verticalEllipsis {    margin-left: 35px;    /* base64 encoded version of images-liveeditor/VEllipsis.png */    width: 12px;    height: 30px;    background-repeat: no-repeat;    background-image: url("");}
.S12 { border-left: 1px solid rgb(233, 233, 233); border-right: 1px solid rgb(233, 233, 233); border-top: 1px solid rgb(233, 233, 233); border-bottom: 1px solid rgb(233, 233, 233); border-radius: 0px; padding: 6px 45px 4px 13px; line-height: 17.234px; min-height: 18px; white-space: nowrap; color: rgb(0, 0, 0); font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 14px;  }
.S13 { margin: 10px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: normal; color: rgb(0, 0, 0); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: normal; text-align: left;  }
.S14 { border-left: 1px solid rgb(233, 233, 233); border-right: 1px solid rgb(233, 233, 233); border-top: 1px solid rgb(233, 233, 233); border-bottom: 0px none rgb(0, 0, 0); border-radius: 0px; padding: 6px 45px 0px 13px; line-height: 17.234px; min-height: 18px; white-space: nowrap; color: rgb(0, 0, 0); font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 14px;  }
.S15 { border-left: 1px solid rgb(233, 233, 233); border-right: 1px solid rgb(233, 233, 233); border-top: 0px none rgb(0, 0, 0); border-bottom: 1px solid rgb(233, 233, 233); border-radius: 0px 0px 4px 4px; padding: 0px 45px 4px 13px; line-height: 17.234px; min-height: 18px; white-space: nowrap; color: rgb(0, 0, 0); font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 14px;  }
.S16 { border-left: 1px solid rgb(233, 233, 233); border-right: 1px solid rgb(233, 233, 233); border-top: 1px solid rgb(233, 233, 233); border-bottom: 1px solid rgb(233, 233, 233); border-radius: 4px; padding: 6px 45px 4px 13px; line-height: 17.234px; min-height: 18px; white-space: nowrap; color: rgb(0, 0, 0); font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 14px;  }
.S17 { border-left: 1px solid rgb(233, 233, 233); border-right: 1px solid rgb(233, 233, 233); border-top: 1px solid rgb(233, 233, 233); border-bottom: 1px solid rgb(233, 233, 233); border-radius: 0px 0px 4px 4px; padding: 6px 45px 4px 13px; line-height: 17.234px; min-height: 18px; white-space: nowrap; color: rgb(0, 0, 0); font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 14px;  }</style></head><body><div class = rtcContent><h1  class = 'S0'><span>Model manipulation</span></h1><div  class = 'S1'><span style=' font-weight: bold;'>Author(s): Vanja Vlasov, Systems Biochemistry Group, LCSB, University of Luxembourg,</span></div><div  class = 'S1'><span style=' font-weight: bold;'>Thomas Pfau,  Systems Biology Group, LSRU, University of Luxembourg.</span></div><div  class = 'S1'><span style=' font-weight: bold;'>Reviewer(s): Ines Thiele, Systems Biochemistry Group, LCSB, University of Luxembourg. </span></div><div  class = 'S1'><span style=' font-weight: bold;'>Catherine Clancy, Systems Biochemistry Group, LCSB, University of Luxembourg.</span></div><div  class = 'S1'><span style=' font-weight: bold;'>Stefania Magnusdottir, Molecular Systems Physiology Group, LCSB, University of Luxembourg.</span></div><h2  class = 'S2'><span>INTRODUCTION</span></h2><div  class = 'S1'><span>In this tutorial, we will do a manipulation with a simple model of the first few reactions of the glycolysis metabolic pathway as created in the "Model Creation" tutorial.</span></div><div  class = 'S1'><span>Glycolysis is the metabolic pathway that occurs in most organisms in the cytosol of the cell. First, we will use the beginning of that pathway to create a simple constraint-based metabolic network (Figure 1).</span></div><div  class = 'S3'><img class = "imageNode" src = "" width = "620" height = "161" alt = "" style = "vertical-align: baseline"></img></div><div  class = 'S1'><span>                                                                   Figure 1: A small metabolic network consisting of the seven reactions in the glycolysis pathway. </span></div><div  class = 'S1'><span>At the beginning of the reconstruction, the initial step is to assess the integrity of the draft reconstruction. Furthermore, an evaluation of accuracy is needed: check necessity of each reaction and metabolite,  the accuracy of the stoichiometry, and direction and reversibility of the reactions.</span></div><div  class = 'S1'><span>The metabolites structures and reactions are from the Virtual Metabolic Human database (VMH, </span><a href = "http://vmh.life/"><span>http://vmh.life</span></a><span>).</span></div><div  class = 'S1'><span>After creating or loading the model and to simulate different model conditions, the model can be modified, such as:</span></div><ul  class = 'S4'><li  class = 'S5'><span>Creating, adding and handling reactions;</span></li><li  class = 'S5'><span>Adding exchange, sink and demand reactions;</span></li><li  class = 'S5'><span>Altering reaction bounds;</span></li><li  class = 'S5'><span>Altering reactions;</span></li><li  class = 'S5'><span>Removing reactions and metabolites;</span></li><li  class = 'S5'><span>Searching for duplicates and comparison of two models;</span></li><li  class = 'S5'><span>Changing the model objective;</span></li><li  class = 'S5'><span>Changing the direction of reaction(s);</span></li><li  class = 'S5'><span>Creating gene-reaction-associations ('GPRs');</span></li><li  class = 'S5'><span>Extracting a subnetwork</span></li></ul><h2  class = 'S6'><span>EQUIPMENT SETUP</span></h2><div  class = 'S1'><span>Start CobraToolbox</span></div><div class="CodeBlock"><div class="inlineWrapper outputs"><div  class = 'S7'><span style="white-space: normal"><span >initCobraToolbox(false) </span><span style="color: rgb(2, 128, 9);">% false, as we don't want to update;</span></span></div><div  class = 'S8'><div class="inlineElement eoOutputWrapper embeddedOutputsTextElement scrollableOutput" uid="D0AE585B" data-testid="output_0" data-width="420" data-height="885" data-hashorizontaloverflow="true" style="width: 450px; max-height: 261px; white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><div class="textElement" style="white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;">      _____   _____   _____   _____     _____     |
     /  ___| /  _  \ |  _  \ |  _  \   / ___ \    |   COnstraint-Based Reconstruction and Analysis
     | |     | | | | | |_| | | |_| |  | |___| |   |   The COBRA Toolbox - 2017
     | |     | | | | |  _  { |  _  /  |  ___  |   |
     | |___  | |_| | | |_| | | | \ \  | |   | |   |   Documentation:
     \_____| \_____/ |_____/ |_|  \_\ |_|   |_|   |   <a href="http://opencobra.github.io/cobratoolbox" style="white-space: normal; font-style: normal; color: rgb(0, 95, 206); font-size: 12px;">http://opencobra.github.io/cobratoolbox</a>
                                                  | 

 &gt; Checking if git is installed ...  Done.
 &gt; Checking if the repository is tracked using git ...  Done.
 &gt; Checking if curl is installed ...  Done.
 &gt; Checking if remote can be reached ...  Done.
 &gt; Initializing and updating submodules ... Done.
 &gt; Adding all the files of The COBRA Toolbox ...  Done.
 &gt; Define CB map output... set to svg.
 &gt; Retrieving models ...   Done.
 &gt; TranslateSBML is installed and working properly.
 &gt; Configuring solver environment variables ...
   - [*---] ILOG_CPLEX_PATH: /opt/ibm/ILOG/CPLEX_Studio1271/cplex/matlab/x86-64_linux
   - [*---] GUROBI_PATH: /opt/gurobi702/linux64/matlab
   - [----] TOMLAB_PATH :  --&gt; set this path manually after installing the solver ( see <a href="https://opencobra.github.io/cobratoolbox/docs/solvers.html" style="white-space: normal; font-style: normal; color: rgb(0, 95, 206); font-size: 12px;">instructions</a> )
   - [----] MOSEK_PATH :  --&gt; set this path manually after installing the solver ( see <a href="https://opencobra.github.io/cobratoolbox/docs/solvers.html" style="white-space: normal; font-style: normal; color: rgb(0, 95, 206); font-size: 12px;">instructions</a> )
   Done.
 &gt; Checking available solvers and solver interfaces ... Done.
 &gt; Setting default solvers ... Done.
 &gt; Saving the MATLAB path ... Done.
   - The MATLAB path was saved as ~/pathdef.m.

 &gt; Summary of available solvers and solver interfaces

			Support 	   LP 	 MILP 	   QP 	 MIQP 	  NLP
	----------------------------------------------------------------------
	cplex_direct 	full          	    0 	    0 	    0 	    0 	    -
	dqqMinos     	full          	    1 	    - 	    - 	    - 	    -
	glpk         	full          	    1 	    1 	    - 	    - 	    -
	gurobi       	full          	    1 	    1 	    1 	    1 	    -
	ibm_cplex    	full          	    1 	    1 	    1 	    - 	    -
	matlab       	full          	    1 	    - 	    - 	    - 	    1
	mosek        	full          	    0 	    0 	    0 	    - 	    -
	pdco         	full          	    1 	    - 	    1 	    - 	    -
	quadMinos    	full          	    1 	    - 	    - 	    - 	    1
	tomlab_cplex 	full          	    0 	    0 	    0 	    0 	    -
	qpng         	experimental  	    - 	    - 	    1 	    - 	    -
	tomlab_snopt 	experimental  	    - 	    - 	    - 	    - 	    0
	gurobi_mex   	legacy        	    0 	    0 	    0 	    0 	    -
	lindo_old    	legacy        	    0 	    - 	    - 	    - 	    -
	lindo_legacy 	legacy        	    0 	    - 	    - 	    - 	    -
	lp_solve     	legacy        	    1 	    - 	    - 	    - 	    -
	opti         	legacy        	    0 	    0 	    0 	    0 	    0
	----------------------------------------------------------------------
	Total        	-             	    8 	    3 	    4 	    1 	    2

 + Legend: - = not applicable, 0 = solver not compatible or not installed, 1 = solver installed.


 &gt; You can solve LP problems using: 'dqqMinos' - 'glpk' - 'gurobi' - 'ibm_cplex' - 'matlab' - 'pdco' - 'quadMinos' - 'lp_solve' 
 &gt; You can solve MILP problems using: 'glpk' - 'gurobi' - 'ibm_cplex' 
 &gt; You can solve QP problems using: 'gurobi' - 'ibm_cplex' - 'pdco' - 'qpng' 
 &gt; You can solve MIQP problems using: 'gurobi' 
 &gt; You can solve NLP problems using: 'matlab' - 'quadMinos' 

 &gt; Checking for available updates ...
 &gt; The COBRA Toolbox is up-to-date.</div></div></div></div></div><h2  class = 'S6'><span>PROCEDURE</span></h2><h2  class = 'S2'><span>Generate a network</span></h2><div  class = 'S1'><span>A constraint-based metabolic model contains the stoichiometric matrix (</span><span style="font-family: STIXGeneral, STIXGeneral-webfont, serif; font-style: italic; font-weight: normal; color: rgb(0, 0, 0);">S</span><span>) with reactions and metabolites [1].</span></div><div  class = 'S1'><span style="font-family: STIXGeneral, STIXGeneral-webfont, serif; font-style: italic; font-weight: normal; color: rgb(0, 0, 0);">S</span><span> is a stoichiometric representation of metabolic networks corresponding to the reactions in the biochemical pathway. In each column of the </span><span style="font-family: STIXGeneral, STIXGeneral-webfont, serif; font-style: italic; font-weight: normal; color: rgb(0, 0, 0);">S</span><span> is a biochemical reaction (</span><span style="font-family: STIXGeneral, STIXGeneral-webfont, serif; font-style: italic; font-weight: normal; color: rgb(0, 0, 0);">n</span><span>) and in each row is a precise metabolite (</span><span style="font-family: STIXGeneral, STIXGeneral-webfont, serif; font-style: italic; font-weight: normal; color: rgb(0, 0, 0);">m</span><span>). There is a stoichiometric coefficient of zero, which means that metabolite does not participate in that distinct reaction. The coefficient also can be positive when the appropriate metabolite is produced, or negative for every metabolite consumed [1].</span></div><div  class = 'S3'><img class = "imageNode" src = "" width = "574" height = "338" alt = "" style = "vertical-align: baseline"></img></div><div  class = 'S1'><span>Generate a model using the </span><span style=' font-family: monospace;'>createModel()</span><span style=' font-style: italic;'> </span><span>function:</span></div><div class="CodeBlock"><div class="inlineWrapper"><div  class = 'S9'><span style="white-space: normal"><span >ReactionFormulas = {</span><span style="color: rgb(170, 4, 249);">'glc_D[e]  -&gt; glc_D[c]'</span><span >,</span><span style="color: rgb(14, 0, 255);">...</span></span></div></div><div class="inlineWrapper"><div  class = 'S10'><span style="white-space: normal"><span >    </span><span style="color: rgb(170, 4, 249);">'glc_D[c] + atp[c]  -&gt; h[c] + adp[c] + g6p[c]'</span><span >,</span><span style="color: rgb(14, 0, 255);">...</span></span></div></div><div class="inlineWrapper"><div  class = 'S10'><span style="white-space: normal"><span >    </span><span style="color: rgb(170, 4, 249);">'g6p[c]  &lt;=&gt; f6p[c]'</span><span >,</span><span style="color: rgb(14, 0, 255);">...</span></span></div></div><div class="inlineWrapper"><div  class = 'S10'><span style="white-space: normal"><span >    </span><span style="color: rgb(170, 4, 249);">'atp[c] + f6p[c]  -&gt; h[c] + adp[c] + fdp[c]'</span><span >,</span><span style="color: rgb(14, 0, 255);">...</span></span></div></div><div class="inlineWrapper"><div  class = 'S10'><span style="white-space: normal"><span >    </span><span style="color: rgb(170, 4, 249);">'fdp[c] + h2o[c]  -&gt; f6p[c] + pi[c]'</span><span >,</span><span style="color: rgb(14, 0, 255);">...</span></span></div></div><div class="inlineWrapper"><div  class = 'S10'><span style="white-space: normal"><span >    </span><span style="color: rgb(170, 4, 249);">'fdp[c]  -&gt; g3p[c] + dhap[c]'</span><span >,</span><span style="color: rgb(14, 0, 255);">...</span></span></div></div><div class="inlineWrapper"><div  class = 'S10'><span style="white-space: normal"><span >    </span><span style="color: rgb(170, 4, 249);">'dhap[c]  -&gt; g3p[c]'</span><span >};</span></span></div></div><div class="inlineWrapper"><div  class = 'S10'><span style="white-space: normal"><span >ReactionNames = {</span><span style="color: rgb(170, 4, 249);">'GLCt1r'</span><span >, </span><span style="color: rgb(170, 4, 249);">'HEX1'</span><span >, </span><span style="color: rgb(170, 4, 249);">'PGI'</span><span >, </span><span style="color: rgb(170, 4, 249);">'PFK'</span><span >, </span><span style="color: rgb(170, 4, 249);">'FBP'</span><span >, </span><span style="color: rgb(170, 4, 249);">'FBA'</span><span >, </span><span style="color: rgb(170, 4, 249);">'TPI'</span><span >};</span></span></div></div><div class="inlineWrapper"><div  class = 'S10'><span style="white-space: normal"><span >lowerbounds = [-20, 0, -20, 0, 0, -20, -20];</span></span></div></div><div class="inlineWrapper"><div  class = 'S10'><span style="white-space: normal"><span >upperbounds = [20, 20, 20, 20, 20, 20, 20];</span></span></div></div><div class="inlineWrapper"><div  class = 'S10'><span style="white-space: normal"><span >model = createModel(ReactionNames, ReactionNames, ReactionFormulas,</span><span style="color: rgb(14, 0, 255);">...</span></span></div></div><div class="inlineWrapper outputs"><div  class = 'S11'><span style="white-space: normal"><span >                   </span><span style="color: rgb(170, 4, 249);">'lowerBoundList'</span><span >, lowerbounds, </span><span style="color: rgb(170, 4, 249);">'upperBoundList'</span><span >, upperbounds);</span></span></div><div  class = 'S8'><div class="inlineElement eoOutputWrapper embeddedOutputsTextElement" uid="8F1B6111" data-testid="output_1" data-width="420" data-height="18" data-hashorizontaloverflow="false" style="width: 450px; max-height: 261px; white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><div class="textElement" style="white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;">GLCt1r	glc_D[e] 	&lt;=&gt;	glc_D[c] </div></div><div class="inlineElement eoOutputWrapper embeddedOutputsTextElement scrollableOutput" uid="7C50BAEE" data-testid="output_2" data-width="420" data-height="18" data-hashorizontaloverflow="true" style="width: 450px; max-height: 261px; white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><div class="textElement" style="white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;">HEX1	glc_D[c] + atp[c] 	-&gt;	h[c] + adp[c] + g6p[c] </div></div><div class="inlineElement eoOutputWrapper embeddedOutputsTextElement" uid="772203AA" data-testid="output_3" data-width="420" data-height="18" data-hashorizontaloverflow="false" style="width: 450px; max-height: 261px; white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><div class="textElement" style="white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;">PGI	g6p[c] 	&lt;=&gt;	f6p[c] </div></div><div class="inlineElement eoOutputWrapper embeddedOutputsTextElement scrollableOutput" uid="31B40FDC" data-testid="output_4" data-width="420" data-height="18" data-hashorizontaloverflow="true" style="width: 450px; max-height: 261px; white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><div class="textElement" style="white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;">PFK	atp[c] + f6p[c] 	-&gt;	h[c] + adp[c] + fdp[c] </div></div><div class="inlineElement eoOutputWrapper embeddedOutputsTextElement" uid="AC1AB7CC" data-testid="output_5" data-width="420" data-height="18" data-hashorizontaloverflow="false" style="width: 450px; max-height: 261px; white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><div class="textElement" style="white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;">FBP	fdp[c] + h2o[c] 	-&gt;	f6p[c] + pi[c] </div></div><div class="inlineElement eoOutputWrapper embeddedOutputsTextElement" uid="B4E91EAE" data-testid="output_6" data-width="420" data-height="31" data-hashorizontaloverflow="false" style="width: 450px; max-height: 261px; white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><div class="textElement" style="white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;">FBA	fdp[c] 	&lt;=&gt;	g3p[c] + dhap[c] 
TPI	dhap[c] 	&lt;=&gt;	g3p[c] </div></div></div></div></div><div  class = 'S1'><span>We can now have a look at the different model fields created. The stoichiometry is stored in the </span><span style="font-family: STIXGeneral, STIXGeneral-webfont, serif; font-style: italic; font-weight: normal; color: rgb(0, 0, 0);">S</span><span> field of the model, which was described above. Since this is commonly a sparse matrix (i.e. it contains a lot of zeros), it may be useful for your understanding to display the full representation:</span></div><div class="CodeBlock"><div class="inlineWrapper outputs"><div  class = 'S7'><span style="white-space: normal"><span >full(model.S)</span></span></div><div  class = 'S8'><div class="inlineElement eoOutputWrapper embeddedOutputsMatrixElement" uid="F15C2D5D" data-testid="output_7" data-width="420" style="width: 450px;"><div class="matrixElement veSpecifier"><div class="veVariableName variableNameElement" style="width: 420px;"><span>ans = </span><span class="veVariableValueSummary"></span></div><div class="valueContainer" data-layout="{&quot;columnWidth&quot;:43.2,&quot;totalColumns&quot;:&quot;7&quot;,&quot;totalRows&quot;:&quot;12&quot;,&quot;charsPerColumn&quot;:6}"><div class="variableValue" style="width: 304.4px;">    -1     0     0     0     0     0     0
     1    -1     0     0     0     0     0
     0    -1     0    -1     0     0     0
     0     1     0     1     0     0     0
     0     1     0     1     0     0     0
     0     1    -1     0     0     0     0
     0     0     1    -1     1     0     0
     0     0     0     1    -1    -1     0
     0     0     0     0    -1     0     0
     0     0     0     0     1     0     0
</div><div class="horizontalEllipsis hide"></div><div class="verticalEllipsis"></div></div></div></div></div></div></div><div  class = 'S1'><span>It is required for a model to consist of the descriptive fields: </span><span style=' font-family: monospace;'>model.mets</span><span> and </span><span style=' font-family: monospace;'>model.rxns,</span><span> which represent the metabolites and the reactions respectively. </span></div><div class="CodeBlock"><div class="inlineWrapper outputs"><div  class = 'S7'><span style="white-space: normal"><span >model.mets</span></span></div><div  class = 'S8'><div class="inlineElement eoOutputWrapper embeddedOutputsVariableStringElement" uid="F3C4A409" data-testid="output_8" data-width="420" data-height="188" data-hashorizontaloverflow="false" style="width: 450px; max-height: 261px; white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><div class="textElement" style="white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><div style="white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><span class="variableNameElement" style="white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;">ans = </span></div><div style="white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;">    'glc_D[e]'
    'glc_D[c]'
    'atp[c]'
    'h[c]'
    'adp[c]'
    'g6p[c]'
    'f6p[c]'
    'fdp[c]'
    'h2o[c]'
    'pi[c]'
    'g3p[c]'
    'dhap[c]'
</div></div></div></div></div><div class="inlineWrapper outputs"><div  class = 'S12'><span style="white-space: normal"><span >model.rxns</span></span></div><div  class = 'S8'><div class="inlineElement eoOutputWrapper embeddedOutputsVariableStringElement" uid="8F39E841" data-testid="output_9" data-width="420" data-height="118" data-hashorizontaloverflow="false" style="width: 450px; max-height: 261px; white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><div class="textElement" style="white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><div style="white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><span class="variableNameElement" style="white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;">ans = </span></div><div style="white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;">    'GLCt1r'
    'HEX1'
    'PGI'
    'PFK'
    'FBP'
    'FBA'
    'TPI'
</div></div></div></div></div></div><div  class = 'S13'><span>The fields in a COBRA model are commonly column vectors, which is important to note when writing functions manipulating these fields.</span></div><div  class = 'S1'><span>There are a few more fields present in each COBRA model:</span></div><div  class = 'S1'><span style=' font-family: monospace;'>model.lb</span><span>, indicating the lower bounds of each reaction, and </span><span style=' font-family: monospace;'>model.ub</span><span> indicating the upper bound of a reaction.  </span></div><div class="CodeBlock"><div class="inlineWrapper"><div  class = 'S9'><span style="white-space: normal"><span style="color: rgb(2, 128, 9);">% this displays an array with reaction names and flux bounds.</span></span></div></div><div class="inlineWrapper"><div  class = 'S10'><span style="white-space: normal"><span >[{</span><span style="color: rgb(170, 4, 249);">'Reaction ID'</span><span >, </span><span style="color: rgb(170, 4, 249);">'Lower Bound'</span><span >, </span><span style="color: rgb(170, 4, 249);">'Upper Bound'</span><span >};</span><span style="color: rgb(14, 0, 255);">...</span><span style="color: rgb(2, 128, 9);">   </span></span></div></div><div class="inlineWrapper outputs"><div  class = 'S11'><span style="white-space: normal"><span > model.rxns, num2cell(model.lb), num2cell(model.ub)]</span></span></div><div  class = 'S8'><div class="inlineElement eoOutputWrapper embeddedOutputsVariableStringElement" uid="C47569E9" data-testid="output_10" data-width="420" data-height="132" data-hashorizontaloverflow="false" style="width: 450px; max-height: 261px; white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><div class="textElement" style="white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><div style="white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><span class="variableNameElement" style="white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;">ans = </span></div><div style="white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;">    'Reaction ID'    'Lower Bound'    'Upper Bound'
    'GLCt1r'         [        -20]    [         20]
    'HEX1'           [          0]    [         20]
    'PGI'            [        -20]    [         20]
    'PFK'            [          0]    [         20]
    'FBP'            [          0]    [         20]
    'FBA'            [        -20]    [         20]
    'TPI'            [        -20]    [         20]
</div></div></div></div></div><div class="inlineWrapper"><div  class = 'S14'><span style="white-space: normal"><span style="color: rgb(2, 128, 9);">% This is a convenience function which does pretty much the same as the line above.</span></span></div></div><div class="inlineWrapper outputs"><div  class = 'S11'><span style="white-space: normal"><span >printFluxBounds(model);</span></span></div><div  class = 'S8'><div class="inlineElement eoOutputWrapper embeddedOutputsTextElement" uid="028E6ED3" data-testid="output_11" data-width="420" data-height="115" data-hashorizontaloverflow="false" style="width: 450px; max-height: 261px; white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><div class="textElement" style="white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;">Reaction ID	   Lower Bound	   Upper Bound
     GLCt1r	       -20.000	        20.000
       HEX1	         0.000	        20.000
        PGI	       -20.000	        20.000
        PFK	         0.000	        20.000
        FBP	         0.000	        20.000
        FBA	       -20.000	        20.000
        TPI	       -20.000	        20.000</div></div></div></div></div><div  class = 'S1'><span>Before we start to modify the model, it might be useful to store in the workspace some of the current properties of the model:</span></div><div class="CodeBlock"><div class="inlineWrapper outputs"><div  class = 'S7'><span style="white-space: normal"><span >mets_length = length(model.mets)</span></span></div><div  class = 'S8'><div class='variableElement' style='font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 12px; '>mets_length = 12</div></div></div><div class="inlineWrapper outputs"><div  class = 'S12'><span style="white-space: normal"><span >rxns_length = length(model.rxns)</span></span></div><div  class = 'S8'><div class='variableElement' style='font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 12px; '>rxns_length = 7</div></div></div></div><h2  class = 'S6'><span>Creating, adding and handling reactions</span></h2><div  class = 'S1'><span>If we want to add a reaction to the model or modify an existing reaction use the function </span><span style=' font-family: monospace;'>addReaction</span><span>. </span></div><div  class = 'S1'><span>We will add to the model some more reactions from glycolysis. There are two different approaches to adding reactions to a model:</span></div><ol  class = 'S4'><li  class = 'S5'><span>The formula approach</span></li><li  class = 'S5'><span>The list appraoch</span></li></ol><div  class = 'S1'><span style=' font-weight: bold; text-decoration: underline;'>The formula approach</span></div><div class="CodeBlock"><div class="inlineWrapper"><div  class = 'S9'><span style="white-space: normal"><span >model = addReaction(model, </span><span style="color: rgb(170, 4, 249);">'GAPDH'</span><span >,</span><span style="color: rgb(14, 0, 255);">...</span></span></div></div><div class="inlineWrapper outputs"><div  class = 'S11'><span style="white-space: normal"><span >       </span><span style="color: rgb(170, 4, 249);">'reactionFormula'</span><span >, </span><span style="color: rgb(170, 4, 249);">'g3p[c] + nad[c] + 2 pi[c] -&gt; nadh[c] + h[c] + 13bpg[c]'</span><span >);</span></span></div><div  class = 'S8'><div class="inlineElement eoOutputWrapper embeddedOutputsTextElement scrollableOutput" uid="8E88B342" data-testid="output_14" data-width="420" data-height="18" data-hashorizontaloverflow="true" style="width: 450px; max-height: 261px; white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><div class="textElement" style="white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;">GAPDH	2 pi[c] + g3p[c] + nad[c] 	-&gt;	h[c] + nadh[c] + 13bpg[c] </div></div></div></div><div class="inlineWrapper"><div  class = 'S14'><span style="white-space: normal"><span >model = addReaction(model, </span><span style="color: rgb(170, 4, 249);">'PGK'</span><span >,</span><span style="color: rgb(14, 0, 255);">...</span></span></div></div><div class="inlineWrapper outputs"><div  class = 'S11'><span style="white-space: normal"><span >       </span><span style="color: rgb(170, 4, 249);">'reactionFormula'</span><span >, </span><span style="color: rgb(170, 4, 249);">'13bpg[c] + adp[c] -&gt; atp[c] + 3pg[c]'</span><span >);</span></span></div><div  class = 'S8'><div class="inlineElement eoOutputWrapper embeddedOutputsTextElement" uid="EF51EDE4" data-testid="output_15" data-width="420" data-height="18" data-hashorizontaloverflow="false" style="width: 450px; max-height: 261px; white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><div class="textElement" style="white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;">PGK	adp[c] + 13bpg[c] 	-&gt;	atp[c] + 3pg[c] </div></div></div></div><div class="inlineWrapper outputs"><div  class = 'S12'><span style="white-space: normal"><span >model = addReaction(model, </span><span style="color: rgb(170, 4, 249);">'PGM'</span><span >, </span><span style="color: rgb(170, 4, 249);">'reactionFormula'</span><span >, </span><span style="color: rgb(170, 4, 249);">'3pg[c] &lt;=&gt; 2pg[c]' </span><span >);</span></span></div><div  class = 'S8'><div class="inlineElement eoOutputWrapper embeddedOutputsTextElement" uid="1CBB695D" data-testid="output_16" data-width="420" data-height="18" data-hashorizontaloverflow="false" style="width: 450px; max-height: 261px; white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><div class="textElement" style="white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;">PGM	3pg[c] 	&lt;=&gt;	2pg[c] </div></div></div></div></div><div  class = 'S13'><span>Display the stoichiometric matrix after adding reactions (note the enlarge link when you move your mouse over the output to display the full matrix):</span></div><div class="CodeBlock"><div class="inlineWrapper outputs"><div  class = 'S7'><span style="white-space: normal"><span >full(model.S) </span></span></div><div  class = 'S8'><div class="inlineElement eoOutputWrapper embeddedOutputsMatrixElement" uid="B48B52F2" data-testid="output_17" data-width="420" style="width: 450px;"><div class="matrixElement veSpecifier"><div class="veVariableName variableNameElement" style="width: 420px;"><span>ans = </span><span class="veVariableValueSummary"></span></div><div class="valueContainer" data-layout="{&quot;columnWidth&quot;:43.2,&quot;totalColumns&quot;:&quot;10&quot;,&quot;totalRows&quot;:&quot;17&quot;,&quot;charsPerColumn&quot;:6}"><div class="variableValue" style="width: 390.8px;">    -1     0     0     0     0     0     0     0     0     0
     1    -1     0     0     0     0     0     0     0     0
     0    -1     0    -1     0     0     0     0     1     0
     0     1     0     1     0     0     0     1     0     0
     0     1     0     1     0     0     0     0    -1     0
     0     1    -1     0     0     0     0     0     0     0
     0     0     1    -1     1     0     0     0     0     0
     0     0     0     1    -1    -1     0     0     0     0
     0     0     0     0    -1     0     0     0     0     0
     0     0     0     0     1     0     0    -2     0     0
</div><div class="horizontalEllipsis"></div><div class="verticalEllipsis"></div></div></div></div></div></div></div><ul  class = 'S4'><li  class = 'S5'><span>one extra column is added (for added reaction) and 5 new rows (for nadh, nad, 13bpg, 2pg and 3pg metabolites)</span></li></ul><div  class = 'S1'><span>If you want to search for the indecies of reactions in the model, and change the order of the select reactions, use the following functions:</span></div><div class="CodeBlock"><div class="inlineWrapper outputs"><div  class = 'S7'><span style="white-space: normal"><span >rxnID = findRxnIDs(model, model.rxns)</span></span></div><div  class = 'S8'><div class="inlineElement eoOutputWrapper embeddedOutputsMatrixElement" uid="ABFBA67C" data-testid="output_18" data-width="420" style="width: 450px;"><div class="matrixElement veSpecifier"><div class="veVariableName variableNameElement" style="width: 420px;"><span>rxnID = </span><span class="veVariableValueSummary"></span></div><div class="valueContainer" data-layout="{&quot;columnWidth&quot;:43.2,&quot;totalColumns&quot;:&quot;1&quot;,&quot;totalRows&quot;:&quot;10&quot;,&quot;charsPerColumn&quot;:6}"><div class="variableValue" style="width: 45.2px;">     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
</div><div class="horizontalEllipsis hide"></div><div class="verticalEllipsis hide"></div></div></div></div></div></div><div class="inlineWrapper outputs"><div  class = 'S12'><span style="white-space: normal"><span >model.rxns</span></span></div><div  class = 'S8'><div class="inlineElement eoOutputWrapper embeddedOutputsVariableStringElement" uid="4579A946" data-testid="output_19" data-width="420" data-height="160" data-hashorizontaloverflow="false" style="width: 450px; max-height: 261px; white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><div class="textElement" style="white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><div style="white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><span class="variableNameElement" style="white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;">ans = </span></div><div style="white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;">    'GLCt1r'
    'HEX1'
    'PGI'
    'PFK'
    'FBP'
    'FBA'
    'TPI'
    'GAPDH'
    'PGK'
    'PGM'
</div></div></div></div></div><div class="inlineWrapper"><div  class = 'S14'><span style="white-space: normal"><span >model = moveRxn(model, 8, 1);</span></span></div></div><div class="inlineWrapper outputs"><div  class = 'S11'><span style="white-space: normal"><span >model.rxns</span></span></div><div  class = 'S8'><div class="inlineElement eoOutputWrapper embeddedOutputsVariableStringElement" uid="E9B169BD" data-testid="output_20" data-width="420" data-height="160" data-hashorizontaloverflow="false" style="width: 450px; max-height: 261px; white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><div class="textElement" style="white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><div style="white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><span class="variableNameElement" style="white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;">ans = </span></div><div style="white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;">    'GAPDH'
    'GLCt1r'
    'HEX1'
    'PGI'
    'PFK'
    'FBP'
    'FBA'
    'TPI'
    'PGK'
    'PGM'
</div></div></div></div></div></div><div  class = 'S13'><span>While the function </span><span style=' font-family: monospace;'>moveRxn</span><span> does not modify the network structure it can be useful in keeping a model tidy.</span></div><div  class = 'S1'><span style=' font-weight: bold; text-decoration: underline;'>The list approach</span></div><div class="CodeBlock"><div class="inlineWrapper"><div  class = 'S9'><span style="white-space: normal"><span >model = addReaction(model, </span><span style="color: rgb(170, 4, 249);">'GAPDH2'</span><span >,</span><span style="color: rgb(14, 0, 255);">...</span></span></div></div><div class="inlineWrapper"><div  class = 'S10'><span style="white-space: normal"><span >    </span><span style="color: rgb(170, 4, 249);">'metaboliteList'</span><span >, {</span><span style="color: rgb(170, 4, 249);">'g3p[c]'</span><span >, </span><span style="color: rgb(170, 4, 249);">'nad[c]'</span><span >, </span><span style="color: rgb(170, 4, 249);">'pi[c]'</span><span >, </span><span style="color: rgb(170, 4, 249);">'13bpg[c]'</span><span >, </span><span style="color: rgb(170, 4, 249);">'nadh[c]'</span><span >, </span><span style="color: rgb(170, 4, 249);">'h[c]' </span><span >},</span><span style="color: rgb(14, 0, 255);">...</span></span></div></div><div class="inlineWrapper"><div  class = 'S15'><span style="white-space: normal"><span >    </span><span style="color: rgb(170, 4, 249);">'stoichCoeffList'</span><span >, [-1; -1; -2; 1; 1; 1], </span><span style="color: rgb(170, 4, 249);">'reversible'</span><span >, false);</span></span></div></div></div><ul  class = 'S4'><li  class = 'S5'><span> The </span><span style=' font-family: monospace;'>addReaction</span><span> function has the ability to recognize duplicate reactions. No reaction added here since the reaction is recognised to already exist in the model. </span></li></ul><div  class = 'S1'><span>Since the fourth reaction we attempted to add to the model was a duplicate, the number of the reactions in the model should only of increased by three and the number of metabolites in the model should of only increaed by five (13bpg, nad, nadh, 23bpg and 2pg).</span></div><div class="CodeBlock"><div class="inlineWrapper"><div  class = 'S9'><span style="white-space: normal"><span >assert(length(model.rxns) == rxns_length + 3)</span></span></div></div><div class="inlineWrapper"><div  class = 'S15'><span style="white-space: normal"><span >assert(length(model.mets) == mets_length + 5) </span></span></div></div></div><h2  class = 'S6'><span>Adding exchange, sink and demand reactions</span></h2><div  class = 'S1'><span>The are three specific types of reactions in a COBRA model that use and recycle accumulated metabolites, or produce the required metabolites:</span></div><ol  class = 'S4'><li  class = 'S5'><span style=' font-style: italic;'>Exchange reactions </span><span>- are reactions that move metabolites across </span><span style=' font-style: italic;'>in silico </span><span>compartments. These </span><span style=' font-style: italic;'>in silico </span><span>compartments are representive of intra- and inter- cellular membranes.</span></li><li  class = 'S5'><span style=' font-style: italic;'>Sink reactions</span><span> - The metabolites, produced in reactions that are outside of an ambit of the system or in unknown reactions, are supplied to the network with reversible sink reactions.</span></li><li  class = 'S5'><span style=' font-style: italic;'>Demand reactions</span><span> - Irreversible reactions added to the model to consume metabolites that are deposited in the system.</span></li></ol><div  class = 'S1'><span>There are two ways to implement these type of reactions:</span></div><ol  class = 'S4'><li  class = 'S5'><span style=' font-weight: bold;'>Use the</span><span style=' font-weight: bold; font-family: monospace;'> addReaction</span><span style=' font-weight: bold;'> function, detailing the stoichiometric coefficient:</span></li></ol><div class="CodeBlock"><div class="inlineWrapper"><div  class = 'S9'><span style="white-space: normal"><span >model = addReaction(model, </span><span style="color: rgb(170, 4, 249);">'EX_glc_D[e]'</span><span >, </span><span style="color: rgb(170, 4, 249);">'metaboliteList'</span><span >, {</span><span style="color: rgb(170, 4, 249);">'glc_D[e]'</span><span >} ,</span><span style="color: rgb(14, 0, 255);">...</span></span></div></div><div class="inlineWrapper outputs"><div  class = 'S11'><span style="white-space: normal"><span >                    </span><span style="color: rgb(170, 4, 249);">'stoichCoeffList'</span><span >, [-1]);</span></span></div><div  class = 'S8'><div class="inlineElement eoOutputWrapper embeddedOutputsTextElement" uid="CBF05DE1" data-testid="output_21" data-width="420" data-height="18" data-hashorizontaloverflow="false" style="width: 450px; max-height: 261px; white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><div class="textElement" style="white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;">EX_glc_D[e]	glc_D[e] 	&lt;=&gt;	</div></div></div></div></div><div  class = 'S13'><span>    To find exchange reactions in the model use the </span><span style=' font-family: monospace;'>findExcRxns</span><span> function:</span></div><div class="CodeBlock"><div class="inlineWrapper"><div  class = 'S9'><span style="white-space: normal"><span style="color: rgb(2, 128, 9);">% determines whether a reaction is a general exchange reaction and</span></span></div></div><div class="inlineWrapper"><div  class = 'S10'><span style="white-space: normal"><span style="color: rgb(2, 128, 9);">% whether its an uptake.</span></span></div></div><div class="inlineWrapper outputs"><div  class = 'S11'><span style="white-space: normal"><span >[selExc, selUpt] = findExcRxns(model, 0, 1)</span></span></div><div  class = 'S8'><div class="inlineElement eoOutputWrapper embeddedOutputsVariableStringElement" uid="557A48AF" data-testid="output_22" data-width="420" data-height="174" data-hashorizontaloverflow="false" style="width: 450px; max-height: 261px; white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><div class="textElement" style="white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><div style="white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><span class="variableNameElement" style="white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;">selExc = </span></div><div style="white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;">   0
   0
   0
   0
   0
   0
   0
   0
   0
   0
   1
</div></div></div><div class="inlineElement eoOutputWrapper embeddedOutputsVariableStringElement" uid="E644983D" data-testid="output_23" data-width="420" data-height="174" data-hashorizontaloverflow="false" style="width: 450px; max-height: 261px; white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><div class="textElement" style="white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><div style="white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><span class="variableNameElement" style="white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;">selUpt = </span></div><div style="white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;">   0
   0
   0
   0
   0
   0
   0
   0
   0
   0
   0
</div></div></div></div></div></div><div  class = 'S13'><span>         </span><span style=' font-weight: bold;'>2.  Use a utility function to create the specific type of reaction: </span><span style=' font-weight: bold; font-family: monospace;'>addExchangeRxn</span><span style=' font-weight: bold;'>, </span><span style=' font-weight: bold; font-family: monospace;'>addSinkReactions</span><span style=' font-weight: bold;'>, </span><span style=' font-weight: bold; font-family: monospace;'>addDemandReaction</span><span style=' font-weight: bold;'>.</span></div><div class="CodeBlock"><div class="inlineWrapper outputs"><div  class = 'S7'><span style="white-space: normal"><span >model = addExchangeRxn(model, {</span><span style="color: rgb(170, 4, 249);">'glc_D[e]'</span><span >, </span><span style="color: rgb(170, 4, 249);">'glc_D[c]'</span><span >})</span></span></div><div  class = 'S8'><div class="inlineElement eoOutputWrapper embeddedOutputsTextElement" uid="C8431BB8" data-testid="output_24" data-width="420" data-height="31" data-hashorizontaloverflow="false" style="width: 450px; max-height: 261px; white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><div class="textElement" style="white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;">EX_glc_D[e]	glc_D[e] 	&lt;=&gt;	
EX_glc_D[c]	glc_D[c] 	&lt;=&gt;	</div></div><div class="inlineElement eoOutputWrapper embeddedOutputsVariableStringElement" uid="2B4FC86F" data-testid="output_25" data-width="420" data-height="244" data-hashorizontaloverflow="false" style="width: 450px; max-height: 261px; white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><div class="textElement" style="white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><div style="white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><span class="variableNameElement" style="white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;">model = </span></div><div style="white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;">          rxns: {12×1 cell}
             S: [17×12 double]
            lb: [12×1 double]
            ub: [12×1 double]
             c: [12×1 double]
          mets: {17×1 cell}
             b: [17×1 double]
         rules: {12×1 cell}
         genes: {0×1 cell}
        osense: -1
        csense: [17×1 char]
    rxnGeneMat: [12×0 double]
      rxnNames: {12×1 cell}
    subSystems: {12×1 cell}
      metNames: {17×1 cell}
       grRules: {12×1 cell}
</div></div></div></div></div></div><div  class = 'S13'><span>   </span></div><div class="CodeBlock"><div class="inlineWrapper outputs"><div  class = 'S7'><span style="white-space: normal"><span >model = addSinkReactions(model, {</span><span style="color: rgb(170, 4, 249);">'13bpg[c]'</span><span >, </span><span style="color: rgb(170, 4, 249);">'nad[c]'</span><span >})</span></span></div><div  class = 'S8'><div class="inlineElement eoOutputWrapper embeddedOutputsTextElement" uid="186A8471" data-testid="output_26" data-width="420" data-height="31" data-hashorizontaloverflow="false" style="width: 450px; max-height: 261px; white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><div class="textElement" style="white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;">sink_13bpg[c]	13bpg[c] 	&lt;=&gt;	
sink_nad[c]	nad[c] 	&lt;=&gt;	</div></div><div class="inlineElement eoOutputWrapper embeddedOutputsVariableStringElement" uid="F0FDA1E2" data-testid="output_27" data-width="420" data-height="244" data-hashorizontaloverflow="false" style="width: 450px; max-height: 261px; white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><div class="textElement" style="white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><div style="white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><span class="variableNameElement" style="white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;">model = </span></div><div style="white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;">          rxns: {14×1 cell}
             S: [17×14 double]
            lb: [14×1 double]
            ub: [14×1 double]
             c: [14×1 double]
          mets: {17×1 cell}
             b: [17×1 double]
         rules: {14×1 cell}
         genes: {0×1 cell}
        osense: -1
        csense: [17×1 char]
    rxnGeneMat: [14×0 double]
      rxnNames: {14×1 cell}
    subSystems: {14×1 cell}
      metNames: {17×1 cell}
       grRules: {14×1 cell}
</div></div></div></div></div></div><div  class = 'S13'><span></span></div><div class="CodeBlock"><div class="inlineWrapper outputs"><div  class = 'S7'><span style="white-space: normal"><span > model = addDemandReaction(model, {</span><span style="color: rgb(170, 4, 249);">'dhap[c]'</span><span >, </span><span style="color: rgb(170, 4, 249);">'g3p[c]'</span><span >})</span></span></div><div  class = 'S8'><div class="inlineElement eoOutputWrapper embeddedOutputsTextElement" uid="D0B465FB" data-testid="output_28" data-width="420" data-height="31" data-hashorizontaloverflow="false" style="width: 450px; max-height: 261px; white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><div class="textElement" style="white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;">DM_dhap[c]	dhap[c] 	-&gt;	
DM_g3p[c]	g3p[c] 	-&gt;	</div></div><div class="inlineElement eoOutputWrapper embeddedOutputsVariableStringElement" uid="7B139F0A" data-testid="output_29" data-width="420" data-height="244" data-hashorizontaloverflow="false" style="width: 450px; max-height: 261px; white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><div class="textElement" style="white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><div style="white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><span class="variableNameElement" style="white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;">model = </span></div><div style="white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;">          rxns: {16×1 cell}
             S: [17×16 double]
            lb: [16×1 double]
            ub: [16×1 double]
             c: [16×1 double]
          mets: {17×1 cell}
             b: [17×1 double]
         rules: {16×1 cell}
         genes: {0×1 cell}
        osense: -1
        csense: [17×1 char]
    rxnGeneMat: [16×0 double]
      rxnNames: {16×1 cell}
    subSystems: {16×1 cell}
      metNames: {17×1 cell}
       grRules: {16×1 cell}
</div></div></div></div></div></div><h2  class = 'S6'><span>Setting a ratio between the reactions</span></h2><div  class = 'S1'><span>It is important to emphasise that previous knowledge base information should be taken into account when generating a model. If this information is omited, the analysis of a model could be adversely altered and consequent results not representative of the network. </span></div><div  class = 'S1'><span>For instance, if it is known that the flux of one reaction is </span><span style=' font-style: italic;'>X</span><span> times the flux of another reaction, it is recommended to 'couple' (i.e., set a ratio) the reactions in the model. </span></div><div  class = 'S1'><span> E.g. </span><span texencoding="1\text{ }v\text{ }\text{EX}_\text{glc}_D\left\lbrack c\right\rbrack =2\text{ }v\text{ }\text{EX}_\text{glc}_D\left\lbrack e\right\rbrack" style="vertical-align:-6px"><img src="" width="187" height="20" /></span></div><div class="CodeBlock"><div class="inlineWrapper outputs"><div  class = 'S7'><span style="white-space: normal"><span >model = addRatioReaction (model, {</span><span style="color: rgb(170, 4, 249);">'EX_glc_D[c]'</span><span >, </span><span style="color: rgb(170, 4, 249);">'EX_glc_D[e]'</span><span >}, [1; 2])</span></span></div><div  class = 'S8'><div class="inlineElement eoOutputWrapper embeddedOutputsVariableStringElement scrollableOutput" uid="7F684A99" data-testid="output_30" data-width="420" data-height="258" data-hashorizontaloverflow="true" style="width: 450px; max-height: 269px; white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><div class="textElement" style="white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><div style="white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><span class="variableNameElement" style="white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;">model = </span></div><div style="white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;">          rxns: {16×1 cell}
             S: [18×16 double]
            lb: [16×1 double]
            ub: [16×1 double]
             c: [16×1 double]
          mets: {18×1 cell}
             b: [18×1 double]
         rules: {16×1 cell}
         genes: {0×1 cell}
        osense: -1
        csense: [18×1 char]
    rxnGeneMat: [16×0 double]
      rxnNames: {16×1 cell}
    subSystems: {16×1 cell}
      metNames: {18×1 cell}
       grRules: {16×1 cell}
          note: 'EX_glc_D[c] andEX_glc_D[e]are set to have a ratio of1:2.'
</div></div></div></div></div></div><h2  class = 'S6'><span style=' font-weight: bold;'>Constraining the flux boundaries of a reaction</span></h2><div  class = 'S1'><span>In order to respect the transport and exchange potential of a particular metabolite, or to resemble the different conditions in the model, we frequently need to set appropriate limits of the reactions.</span></div><div class="CodeBlock"><div class="inlineWrapper"><div  class = 'S16'><span style="white-space: normal"><span >model = changeRxnBounds(model, </span><span style="color: rgb(170, 4, 249);">'EX_glc_D[e]'</span><span >, -18.5, </span><span style="color: rgb(170, 4, 249);">'l'</span><span >);</span></span></div></div></div><h2  class = 'S6'><span>Modifying reactions</span></h2><div  class = 'S1'><span>The </span><span style=' font-family: monospace;'>addReaction</span><span> function is also a good choice to modify reactions. By supplying to the function a new stoichiometry, the old will be overwritten. </span></div><div  class = 'S1'><span>For example, further up, we added the wrong stoichiometry for the GAP-Dehydrogenase with a coefficient of 2 for phosphate. Print the reaction to visulize:</span></div><div class="CodeBlock"><div class="inlineWrapper outputs"><div  class = 'S7'><span style="white-space: normal"><span >printRxnFormula(model, </span><span style="color: rgb(170, 4, 249);">'rxnAbbrList'</span><span >, </span><span style="color: rgb(170, 4, 249);">'GAPDH'</span><span >);</span></span></div><div  class = 'S8'><div class="inlineElement eoOutputWrapper embeddedOutputsTextElement scrollableOutput" uid="D1A25BA2" data-testid="output_31" data-width="420" data-height="18" data-hashorizontaloverflow="true" style="width: 450px; max-height: 261px; white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><div class="textElement" style="white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;">GAPDH	2 pi[c] + g3p[c] + nad[c] 	-&gt;	h[c] + nadh[c] + 13bpg[c] </div></div></div></div></div><div  class = 'S13'><span>Correct the reaction using </span><span style=' font-family: monospace;'>addReaction:</span><span> with the corrected stoichiometry:</span></div><div class="CodeBlock"><div class="inlineWrapper"><div  class = 'S9'><span style="white-space: normal"><span >model = addReaction(model, </span><span style="color: rgb(170, 4, 249);">'GAPDH'</span><span >,</span><span style="color: rgb(14, 0, 255);">...</span></span></div></div><div class="inlineWrapper"><div  class = 'S10'><span style="white-space: normal"><span >    </span><span style="color: rgb(170, 4, 249);">'metaboliteList'</span><span >, {</span><span style="color: rgb(170, 4, 249);">'g3p[c]'</span><span >, </span><span style="color: rgb(170, 4, 249);">'nad[c]'</span><span >, </span><span style="color: rgb(170, 4, 249);">'pi[c]'</span><span >, </span><span style="color: rgb(170, 4, 249);">'13bpg[c]'</span><span >, </span><span style="color: rgb(170, 4, 249);">'nadh[c]'</span><span >,</span><span style="color: rgb(170, 4, 249);">'h[c]' </span><span >},</span><span style="color: rgb(14, 0, 255);">...</span></span></div></div><div class="inlineWrapper outputs"><div  class = 'S11'><span style="white-space: normal"><span >    </span><span style="color: rgb(170, 4, 249);">'stoichCoeffList'</span><span >, [-1; -1; -1; 1; 1; 1]);</span></span></div><div  class = 'S8'><div class="inlineElement eoOutputWrapper embeddedOutputsTextElement scrollableOutput" uid="E9C26751" data-testid="output_32" data-width="420" data-height="18" data-hashorizontaloverflow="true" style="width: 450px; max-height: 261px; white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><div class="textElement" style="white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;">GAPDH	pi[c] + g3p[c] + nad[c] 	-&gt;	h[c] + nadh[c] + 13bpg[c] </div></div></div></div></div><div  class = 'S13'><span></span></div><div  class = 'S1'><span>We can add a gene rule to the reaction using the </span><span style=' font-family: monospace;'>changeGeneAssociation</span><span> function: </span></div><div class="CodeBlock"><div class="inlineWrapper outputs"><div  class = 'S7'><span style="white-space: normal"><span >model = changeGeneAssociation(model, </span><span style="color: rgb(170, 4, 249);">'GAPDH'</span><span >, </span><span style="color: rgb(170, 4, 249);">'G1 and G2'</span><span >);</span></span></div><div  class = 'S8'><div class="inlineElement eoOutputWrapper embeddedOutputsTextElement" uid="4B79F3E2" data-testid="output_33" data-width="420" data-height="31" data-hashorizontaloverflow="false" style="width: 450px; max-height: 261px; white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><div class="textElement" style="white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;">New gene G1 added to model
New gene G2 added to model</div></div></div></div><div class="inlineWrapper outputs"><div  class = 'S12'><span style="white-space: normal"><span >printRxnFormula(model, </span><span style="color: rgb(170, 4, 249);">'rxnAbbrList'</span><span >, {</span><span style="color: rgb(170, 4, 249);">'GAPDH'</span><span >}, </span><span style="color: rgb(170, 4, 249);">'gprFlag'</span><span >, true);</span></span></div><div  class = 'S8'><div class="inlineElement eoOutputWrapper embeddedOutputsTextElement scrollableOutput" uid="ABDBB3B6" data-testid="output_34" data-width="420" data-height="18" data-hashorizontaloverflow="true" style="width: 450px; max-height: 261px; white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><div class="textElement" style="white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;">GAPDH	pi[c] + g3p[c] + nad[c] 	-&gt;	h[c] + nadh[c] + 13bpg[c] 	G1 and G2</div></div></div></div></div><div  class = 'S13'><span>Alternatively, one can add a gene rule to a reaction using the </span><span style=' font-family: monospace;'>addReaction</span><span> function, and within this function applying the </span><span style=' font-family: monospace;'>geneRule</span><span> input option. </span></div><div class="CodeBlock"><div class="inlineWrapper outputs"><div  class = 'S7'><span style="white-space: normal"><span >model = addReaction(model, </span><span style="color: rgb(170, 4, 249);">'PGK'</span><span >, </span><span style="color: rgb(170, 4, 249);">'geneRule'</span><span >, </span><span style="color: rgb(170, 4, 249);">'G2 or G3'</span><span >, </span><span style="color: rgb(170, 4, 249);">'printLevel'</span><span >, 0);</span></span></div><div  class = 'S8'><div class="inlineElement eoOutputWrapper embeddedOutputsTextElement" uid="F9A31CBE" data-testid="output_35" data-width="420" data-height="18" data-hashorizontaloverflow="false" style="width: 450px; max-height: 261px; white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><div class="textElement" style="white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;">New gene G3 added to model</div></div></div></div><div class="inlineWrapper outputs"><div  class = 'S12'><span style="white-space: normal"><span >printRxnFormula(model, </span><span style="color: rgb(170, 4, 249);">'gprFlag'</span><span >, true);</span></span></div><div  class = 'S8'><div class="inlineElement eoOutputWrapper embeddedOutputsTextElement scrollableOutput" uid="484E2AD2" data-testid="output_36" data-width="420" data-height="227" data-hashorizontaloverflow="true" style="width: 450px; max-height: 261px; white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><div class="textElement" style="white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;">GAPDH	pi[c] + g3p[c] + nad[c] 	-&gt;	h[c] + nadh[c] + 13bpg[c] 	G1 and G2
GLCt1r	glc_D[e] 	&lt;=&gt;	glc_D[c] 	
HEX1	glc_D[c] + atp[c] 	-&gt;	h[c] + adp[c] + g6p[c] 	
PGI	g6p[c] 	&lt;=&gt;	f6p[c] 	
PFK	atp[c] + f6p[c] 	-&gt;	h[c] + adp[c] + fdp[c] 	
FBP	fdp[c] + h2o[c] 	-&gt;	f6p[c] + pi[c] 	
FBA	fdp[c] 	&lt;=&gt;	g3p[c] + dhap[c] 	
TPI	dhap[c] 	&lt;=&gt;	g3p[c] 	
PGK	adp[c] + 13bpg[c] 	-&gt;	atp[c] + 3pg[c] 	G2 or G3
PGM	3pg[c] 	&lt;=&gt;	2pg[c] 	
EX_glc_D[e]	glc_D[e] 	&lt;=&gt;	2 Ratio_EX_glc_D[c]_EX_glc_D[e] 	
EX_glc_D[c]	glc_D[c] + Ratio_EX_glc_D[c]_EX_glc_D[e] 	&lt;=&gt;		
sink_13bpg[c]	13bpg[c] 	&lt;=&gt;		
sink_nad[c]	nad[c] 	&lt;=&gt;		
DM_dhap[c]	dhap[c] 	-&gt;		
DM_g3p[c]	g3p[c] 	-&gt;		</div></div></div></div></div><h2  class = 'S6'><span>Remove reactions and metabolites</span></h2><div  class = 'S1'><span>To delete reactions from the model, use the </span><span style=' font-family: monospace;'>removeRxns</span><span> function:</span></div><div class="CodeBlock"><div class="inlineWrapper"><div  class = 'S9'><span style="white-space: normal"><span > model = removeRxns(model, {</span><span style="color: rgb(170, 4, 249);">'EX_glc_D[c]'</span><span >, </span><span style="color: rgb(170, 4, 249);">'EX_glc_D[e]'</span><span >, </span><span style="color: rgb(170, 4, 249);">'sink_13bpg[c]'</span><span >, </span><span style="color: rgb(14, 0, 255);">...</span></span></div></div><div class="inlineWrapper"><div  class = 'S10'><span style="white-space: normal"><span >                             </span><span style="color: rgb(170, 4, 249);">'sink_nad[c]'</span><span >, </span><span style="color: rgb(170, 4, 249);">'DM_dhap[c]'</span><span >, </span><span style="color: rgb(170, 4, 249);">'DM_g3p[c]'</span><span >});</span></span></div></div><div class="inlineWrapper"><div  class = 'S10'></div></div><div class="inlineWrapper"><div  class = 'S15'><span style="white-space: normal"><span > assert(rxns_length + 3 == length(model.rxns));</span></span></div></div></div><ul  class = 'S4'><li  class = 'S5'><span>The reaction length was updated since a number of reactions were removed from the model. </span></li></ul><div  class = 'S1'><span>To remove metabolites from the model, use the </span><span style=' font-family: monospace;'>removeMetabolites()</span><span> function:</span></div><div class="CodeBlock"><div class="inlineWrapper"><div  class = 'S9'><span style="white-space: normal"><span >  model = removeMetabolites(model, {</span><span style="color: rgb(170, 4, 249);">'3pg[c]'</span><span >, </span><span style="color: rgb(170, 4, 249);">'2pg[c]'</span><span >}, false);</span></span></div></div><div class="inlineWrapper outputs"><div  class = 'S11'><span style="white-space: normal"><span >  printRxnFormula(model, </span><span style="color: rgb(170, 4, 249);">'rxnAbbrList'</span><span >, {</span><span style="color: rgb(170, 4, 249);">'GAPDH'</span><span >}, </span><span style="color: rgb(170, 4, 249);">'gprFlag'</span><span >, true);</span></span></div><div  class = 'S8'><div class="inlineElement eoOutputWrapper embeddedOutputsTextElement scrollableOutput" uid="A202396B" data-testid="output_37" data-width="420" data-height="18" data-hashorizontaloverflow="true" style="width: 450px; max-height: 261px; white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><div class="textElement" style="white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;">GAPDH	pi[c] + g3p[c] + nad[c] 	-&gt;	h[c] + nadh[c] + 13bpg[c] 	G1 and G2</div></div></div></div></div><ul  class = 'S4'><li  class = 'S5'><span>The '</span><span style=' font-family: monospace;'>GAPDH</span><span>' reaction is still present in the model since there are other metabolites in the reaction, not just the metabolites we tried to delete. The 'false' input option of the</span><span style=' font-family: monospace;'> removeMetabolites</span><span> function indictes that only empty reactions should be removed.</span></li></ul><div  class = 'S1'><span>To delete metabolites and reactions with zero rows and columns, the </span><span style=' font-family: monospace;'>removeTrivialStoichiometry()</span><span> function can be used:</span></div><div class="CodeBlock"><div class="inlineWrapper outputs"><div  class = 'S7'><span style="white-space: normal"><span >  model = removeTrivialStoichiometry(model)</span></span></div><div  class = 'S8'><div class="inlineElement eoOutputWrapper embeddedOutputsVariableStringElement scrollableOutput" uid="69FE1C11" data-testid="output_38" data-width="420" data-height="258" data-hashorizontaloverflow="true" style="width: 450px; max-height: 269px; white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><div class="textElement" style="white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><div style="white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><span class="variableNameElement" style="white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;">model = </span></div><div style="white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;">          rxns: {9×1 cell}
             S: [15×9 double]
            lb: [9×1 double]
            ub: [9×1 double]
             c: [9×1 double]
          mets: {15×1 cell}
             b: [15×1 double]
         rules: {9×1 cell}
         genes: {3×1 cell}
        osense: -1
        csense: [15×1 char]
    rxnGeneMat: [9×3 double]
      rxnNames: {9×1 cell}
    subSystems: {9×1 cell}
      metNames: {15×1 cell}
       grRules: {9×1 cell}
          note: 'EX_glc_D[c] andEX_glc_D[e]are set to have a ratio of1:2.'
</div></div></div></div></div></div><h2  class = 'S6'><span>Search for duplicate reactions and comparison of two models</span></h2><div  class = 'S1'><span>Since genome-scale metabolic models are expanding every day [2], the need to compare models is also growing. The elementary functions in The Cobra Toolbox can support simultaneous structural analysis and comparison.</span></div><div  class = 'S1'><span>Checking for reaction duplicates with the </span><span style=' font-family: monospace;'>checkDuplicateRxn()</span><span> function (i.e. by reaction abbreviation), using either the method: </span></div><ul  class = 'S4'><li  class = 'S5'><span style=' text-decoration: underline;'>'</span><span style=' text-decoration: underline; font-family: monospace;'>S</span><span style=' text-decoration: underline;'>'</span><span> (does not detect reverse reactions), or </span></li><li  class = 'S5'><span style=' text-decoration: underline;'>'</span><span style=' text-decoration: underline; font-family: monospace;'>FR</span><span style=' text-decoration: underline;'>'</span><span> (neglects reactions direction).</span></li></ul><div  class = 'S1'><span>For demonstration of the S method, first check for dupicates and then add the duplicate reaction to the model:</span></div><div class="CodeBlock"><div class="inlineWrapper outputs"><div  class = 'S7'><span style="white-space: normal"><span >[model, removedRxn, rxnRelationship] = checkDuplicateRxn(model, </span><span style="color: rgb(170, 4, 249);">'S'</span><span >, 1, 1);</span></span></div><div  class = 'S8'><div class="inlineElement eoOutputWrapper embeddedOutputsTextElement" uid="B7AC28D1" data-testid="output_39" data-width="420" data-height="31" data-hashorizontaloverflow="false" style="width: 450px; max-height: 261px; white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><div class="textElement" style="white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;">Checking for reaction duplicates by stoichiometry ...
 no duplicates found.</div></div></div></div><div class="inlineWrapper outputs"><div  class = 'S12'><span style="white-space: normal"><span >printRxnFormula(model, </span><span style="color: rgb(170, 4, 249);">'rxnAbbrList'</span><span >, {</span><span style="color: rgb(170, 4, 249);">'GLCt1r'</span><span >});</span></span></div><div  class = 'S8'><div class="inlineElement eoOutputWrapper embeddedOutputsTextElement" uid="F5091404" data-testid="output_40" data-width="420" data-height="18" data-hashorizontaloverflow="false" style="width: 450px; max-height: 261px; white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><div class="textElement" style="white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;">GLCt1r	glc_D[e] 	&lt;=&gt;	glc_D[c] </div></div></div></div><div class="inlineWrapper"><div  class = 'S14'><span style="white-space: normal"><span >model = addReaction(model, </span><span style="color: rgb(170, 4, 249);">'GLCt1r_duplicate_reverse'</span><span >,</span><span style="color: rgb(14, 0, 255);">...</span></span></div></div><div class="inlineWrapper"><div  class = 'S10'><span style="white-space: normal"><span >                    </span><span style="color: rgb(170, 4, 249);">'metaboliteList'</span><span >, {</span><span style="color: rgb(170, 4, 249);">'glc_D[e]'</span><span >, </span><span style="color: rgb(170, 4, 249);">'glc_D[c]'</span><span >},</span><span style="color: rgb(14, 0, 255);">...</span></span></div></div><div class="inlineWrapper"><div  class = 'S10'><span style="white-space: normal"><span >                    </span><span style="color: rgb(170, 4, 249);">'stoichCoeffList'</span><span >, [1 -1], </span><span style="color: rgb(170, 4, 249);">'lowerBound'</span><span >, 0, </span><span style="color: rgb(14, 0, 255);">...</span></span></div></div><div class="inlineWrapper outputs"><div  class = 'S11'><span style="white-space: normal"><span >                    </span><span style="color: rgb(170, 4, 249);">'upperBound'</span><span >, 20, </span><span style="color: rgb(170, 4, 249);">'checkDuplicate'</span><span >, 0);</span></span></div><div  class = 'S8'><div class="inlineElement eoOutputWrapper embeddedOutputsTextElement scrollableOutput" uid="A9CD912E" data-testid="output_41" data-width="420" data-height="18" data-hashorizontaloverflow="true" style="width: 450px; max-height: 261px; white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><div class="textElement" style="white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;">GLCt1r_duplicate_reverse	glc_D[c] 	-&gt;	glc_D[e] </div></div></div></div></div><div  class = 'S13'><span style=' text-decoration: underline;'>Detecting duplicates using the S method:</span></div><div class="CodeBlock"><div class="inlineWrapper"><div  class = 'S9'><span style="white-space: normal"><span >method = </span><span style="color: rgb(170, 4, 249);">'S'</span><span >; </span></span></div></div><div class="inlineWrapper outputs"><div  class = 'S11'><span style="white-space: normal"><span >[model,removedRxn, rxnRelationship] = checkDuplicateRxn(model, method, 1, 1);</span></span></div><div  class = 'S8'><div class="inlineElement eoOutputWrapper embeddedOutputsTextElement" uid="6C45AF44" data-testid="output_42" data-width="420" data-height="31" data-hashorizontaloverflow="false" style="width: 450px; max-height: 261px; white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><div class="textElement" style="white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;">Checking for reaction duplicates by stoichiometry ...
 no duplicates found.</div></div></div></div></div><ul  class = 'S4'><li  class = 'S5'><span>The GLCt1r_duplicate_reverse reaction </span><span style=' text-decoration: underline;'>is not detected</span><span> as a duplicate reaction therefore will not be removed as the S method </span><span style=' text-decoration: underline;'>does not detect</span><span> a reverse reactions.</span></li><li  class = 'S5'><span>Reevaluate the reaction length to show this:</span></li></ul><div class="CodeBlock"><div class="inlineWrapper"><div  class = 'S16'><span style="white-space: normal"><span >assert(rxns_length + 3 == length(model.rxns));</span></span></div></div></div><div  class = 'S13'><span style=' text-decoration: underline;'>Detecting duplicates using the FR method:</span></div><div class="CodeBlock"><div class="inlineWrapper"><div  class = 'S9'><span style="white-space: normal"><span >method = </span><span style="color: rgb(170, 4, 249);">'FR'</span><span >;</span></span></div></div><div class="inlineWrapper outputs"><div  class = 'S11'><span style="white-space: normal"><span >[model, removedRxn, rxnRelationship] = checkDuplicateRxn(model, method, 1, 1)</span></span></div><div  class = 'S8'><div class="inlineElement eoOutputWrapper embeddedOutputsTextElement scrollableOutput" uid="CF1C3E6D" data-testid="output_43" data-width="420" data-height="45" data-hashorizontaloverflow="true" style="width: 450px; max-height: 261px; white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><div class="textElement" style="white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;">Checking for reaction duplicates by stoichiometry (up to orientation) ...
     Keep: 	GLCt1r	glc_D[e] 	&lt;=&gt;	glc_D[c] 
Duplicate: 	GLCt1r_duplicate_reverse	glc_D[c] 	-&gt;	glc_D[e] </div></div><div class="inlineElement eoOutputWrapper embeddedOutputsVariableStringElement scrollableOutput" uid="7686C353" data-testid="output_44" data-width="420" data-height="258" data-hashorizontaloverflow="true" style="width: 450px; max-height: 269px; white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><div class="textElement" style="white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><div style="white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><span class="variableNameElement" style="white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;">model = </span></div><div style="white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;">          rxns: {9×1 cell}
             S: [15×9 double]
            lb: [9×1 double]
            ub: [9×1 double]
             c: [9×1 double]
          mets: {15×1 cell}
             b: [15×1 double]
         rules: {9×1 cell}
         genes: {3×1 cell}
        osense: -1
        csense: [15×1 char]
    rxnGeneMat: [9×3 double]
      rxnNames: {9×1 cell}
    subSystems: {9×1 cell}
      metNames: {15×1 cell}
       grRules: {9×1 cell}
          note: 'EX_glc_D[c] andEX_glc_D[e]are set to have a ratio of1:2.'
</div></div></div><div class='variableElement' style='font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 12px; '>removedRxn = 10</div><div class='variableElement' style='font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 12px; '>rxnRelationship = 2</div></div></div><div class="inlineWrapper"><div  class = 'S17'><span style="white-space: normal"><span >assert(rxns_length + 2 == length(model.rxns))</span></span></div></div></div><ul  class = 'S4'><li  class = 'S5'><span>The GLCt1r_duplicate_reverse reaction </span><span style=' text-decoration: underline;'>is detected</span><span> as a duplicate reaction therefore will not be removed as the FR method </span><span style=' text-decoration: underline;'>does detect</span><span> a reverse reactions.</span></li></ul><div  class = 'S1'><span>Checking for non-unique r</span><span>eactions and metabolites in a model using the</span><span style=' font-family: monospace;'> checkCobraModelUnique()</span><span> function: </span></div><div class="CodeBlock"><div class="inlineWrapper outputs"><div  class = 'S7'><span style="white-space: normal"><span >model = checkCobraModelUnique(model, false)</span></span></div><div  class = 'S8'><div class="inlineElement eoOutputWrapper embeddedOutputsVariableStringElement scrollableOutput" uid="A7AAAA53" data-testid="output_47" data-width="420" data-height="258" data-hashorizontaloverflow="true" style="width: 450px; max-height: 269px; white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><div class="textElement" style="white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><div style="white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><span class="variableNameElement" style="white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;">model = </span></div><div style="white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;">          rxns: {9×1 cell}
             S: [15×9 double]
            lb: [9×1 double]
            ub: [9×1 double]
             c: [9×1 double]
          mets: {15×1 cell}
             b: [15×1 double]
         rules: {9×1 cell}
         genes: {3×1 cell}
        osense: -1
        csense: [15×1 char]
    rxnGeneMat: [9×3 double]
      rxnNames: {9×1 cell}
    subSystems: {9×1 cell}
      metNames: {15×1 cell}
       grRules: {9×1 cell}
          note: 'EX_glc_D[c] andEX_glc_D[e]are set to have a ratio of1:2.'
</div></div></div></div></div></div><ul  class = 'S4'><li  class = 'S5'><span>Input option 'false' means the function will not renames non-unique reaction names and metabolites</span></li></ul><h2  class = 'S6'><span>Changing the model's objective</span></h2><div  class = 'S1'><span>Simulating specific objectives of a model is often necessary in order to perform an investigation of different conditions. One of the fundamental objectives is optimal growth [3]. The model can be modified to get different conditions by changing the model objective.</span></div><div  class = 'S1'><span>One reaction is set as the objective, and has an objective coefficient of 0.5:</span></div><div class="CodeBlock"><div class="inlineWrapper"><div  class = 'S16'><span style="white-space: normal"><span >modelNew = changeObjective(model, </span><span style="color: rgb(170, 4, 249);">'GLCt1r'</span><span >, 0.5);</span></span></div></div></div><div  class = 'S13'><span>Multiple reactions are set collectively as the objective, and the default objective coefficient of 1 for each reaction:</span></div><div class="CodeBlock"><div class="inlineWrapper"><div  class = 'S16'><span style="white-space: normal"><span >modelNew = changeObjective(model, {</span><span style="color: rgb(170, 4, 249);">'PGI'</span><span >; </span><span style="color: rgb(170, 4, 249);">'PFK'</span><span >; </span><span style="color: rgb(170, 4, 249);">'FBP'</span><span >});</span></span></div></div></div><h2  class = 'S6'><span>The direction of reactions </span></h2><div  class = 'S1'><span>Sometimes it may be important to have all reactions in a model as irreversible reactions (i.e. only allow a forward reaction / positive flux in reactions). This can be important if, for example, the absolute flux values are of interest, and negative flux would reduce an objective while it should actually increase it. The COBRA Toolbox offers functionality to change all reactions in a model to an irreversible format. IT does this by splitting all reversible reactions and adjusting the respective lower and upper bounds, such that the model capacities stay the same. </span></div><div  class = 'S1'><span>Let us see, how the glycolysis model currently looks:</span></div><div class="CodeBlock"><div class="inlineWrapper outputs"><div  class = 'S7'><span style="white-space: normal"><span >printRxnFormula(model);</span></span></div><div  class = 'S8'><div class="inlineElement eoOutputWrapper embeddedOutputsTextElement scrollableOutput" uid="0A000381" data-testid="output_48" data-width="420" data-height="129" data-hashorizontaloverflow="true" style="width: 450px; max-height: 261px; white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><div class="textElement" style="white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;">GAPDH	pi[c] + g3p[c] + nad[c] 	-&gt;	h[c] + nadh[c] + 13bpg[c] 
GLCt1r	glc_D[e] 	&lt;=&gt;	glc_D[c] 
HEX1	glc_D[c] + atp[c] 	-&gt;	h[c] + adp[c] + g6p[c] 
PGI	g6p[c] 	&lt;=&gt;	f6p[c] 
PFK	atp[c] + f6p[c] 	-&gt;	h[c] + adp[c] + fdp[c] 
FBP	fdp[c] + h2o[c] 	-&gt;	f6p[c] + pi[c] 
FBA	fdp[c] 	&lt;=&gt;	g3p[c] + dhap[c] 
TPI	dhap[c] 	&lt;=&gt;	g3p[c] 
PGK	adp[c] + 13bpg[c] 	-&gt;	atp[c] </div></div></div></div></div><div  class = 'S13'><span>To convert a model to a</span><span>n irreversible model use the </span><span style=' font-style: italic;'>convertToIrreversible</span><span> command:</span></div><div class="CodeBlock"><div class="inlineWrapper"><div  class = 'S16'><span style="white-space: normal"><span >[modelIrrev, matchRev, rev2irrev, irrev2rev] = convertToIrreversible(model);</span></span></div></div></div><div  class = 'S13'><span>Compare the irreversible model with the original model:</span></div><div class="CodeBlock"><div class="inlineWrapper outputs"><div  class = 'S7'><span style="white-space: normal"><span >printRxnFormula(modelIrrev);</span></span></div><div  class = 'S8'><div class="inlineElement eoOutputWrapper embeddedOutputsTextElement scrollableOutput" uid="0FDF605B" data-testid="output_49" data-width="420" data-height="185" data-hashorizontaloverflow="true" style="width: 450px; max-height: 261px; white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><div class="textElement" style="white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;">GAPDH	pi[c] + g3p[c] + nad[c] 	-&gt;	h[c] + nadh[c] + 13bpg[c] 
GLCt1r_f	glc_D[e] 	-&gt;	glc_D[c] 
HEX1	glc_D[c] + atp[c] 	-&gt;	h[c] + adp[c] + g6p[c] 
PGI_f	g6p[c] 	-&gt;	f6p[c] 
PFK	atp[c] + f6p[c] 	-&gt;	h[c] + adp[c] + fdp[c] 
FBP	fdp[c] + h2o[c] 	-&gt;	f6p[c] + pi[c] 
FBA_f	fdp[c] 	-&gt;	g3p[c] + dhap[c] 
TPI_f	dhap[c] 	-&gt;	g3p[c] 
PGK	adp[c] + 13bpg[c] 	-&gt;	atp[c] 
GLCt1r_b	glc_D[c] 	-&gt;	glc_D[e] 
PGI_b	f6p[c] 	-&gt;	g6p[c] 
FBA_b	g3p[c] + dhap[c] 	-&gt;	fdp[c] 
TPI_b	g3p[c] 	-&gt;	dhap[c] </div></div></div></div></div><ul  class = 'S4'><li  class = 'S5'><span>You will notice, that there </span><span>are more reactions in this model and that all reactions which have a lower bound &lt; 0 are split in two. </span></li></ul><div  class = 'S1'><span>There is also a function to convert an irreversible model to a reversible model:</span></div><div class="CodeBlock"><div class="inlineWrapper"><div  class = 'S16'><span style="white-space: normal"><span >modelRev = convertToReversible(modelIrrev);</span></span></div></div></div><div  class = 'S13'><span>If we now compare the reactions of this mod</span><span>el with those from the original model, they should look the same.</span></div><div class="CodeBlock"><div class="inlineWrapper outputs"><div  class = 'S7'><span style="white-space: normal"><span >printRxnFormula(modelRev);</span></span></div><div  class = 'S8'><div class="inlineElement eoOutputWrapper embeddedOutputsTextElement scrollableOutput" uid="44BB3868" data-testid="output_50" data-width="420" data-height="129" data-hashorizontaloverflow="true" style="width: 450px; max-height: 261px; white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><div class="textElement" style="white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;">GAPDH	pi[c] + g3p[c] + nad[c] 	-&gt;	h[c] + nadh[c] + 13bpg[c] 
GLCt1r	glc_D[e] 	&lt;=&gt;	glc_D[c] 
HEX1	glc_D[c] + atp[c] 	-&gt;	h[c] + adp[c] + g6p[c] 
PGI	g6p[c] 	&lt;=&gt;	f6p[c] 
PFK	atp[c] + f6p[c] 	-&gt;	h[c] + adp[c] + fdp[c] 
FBP	fdp[c] + h2o[c] 	-&gt;	f6p[c] + pi[c] 
FBA	fdp[c] 	&lt;=&gt;	g3p[c] + dhap[c] 
TPI	dhap[c] 	&lt;=&gt;	g3p[c] 
PGK	adp[c] + 13bpg[c] 	-&gt;	atp[c] </div></div></div></div></div><h2  class = 'S6'><span>Create gene-reaction-associations (GPRs) from scratch.</span></h2><div  class = 'S1'><span>Assign the GPR '(G1) or (G2)' to the reaction HEX1</span></div><div class="CodeBlock"><div class="inlineWrapper"><div  class = 'S16'><span style="white-space: normal"><span >model = changeGeneAssociation(model, </span><span style="color: rgb(170, 4, 249);">'HEX1'</span><span >, </span><span style="color: rgb(170, 4, 249);">'(G1) or (G2)'</span><span >);</span></span></div></div></div><h2  class = 'S6'><span>Replace an existing GPRs with a new one. </span></h2><div  class = 'S1'><span>Here, we will search for all instances of a specific GPR ('G1 and G2 ') and replace it with a new one ('G1 or G4').</span></div><div  class = 'S1'><span>Define the old and the new GPRs. </span></div><div class="CodeBlock"><div class="inlineWrapper"><div  class = 'S9'><span style="white-space: normal"><span >GPRsReplace = {</span><span style="color: rgb(170, 4, 249);">'G1 and G2'</span><span >	</span><span style="color: rgb(170, 4, 249);">'G1 or G4'</span><span >};</span></span></div></div><div class="inlineWrapper"><div  class = 'S10'><span style="white-space: normal"><span style="color: rgb(14, 0, 255);">for</span><span >  i = 1 : size(GPRsReplace, 1)</span></span></div></div><div class="inlineWrapper"><div  class = 'S10'><span style="white-space: normal"><span >    oldGPRrxns = find(strcmp(model.grRules, GPRsReplace{i, 1}));</span><span style="color: rgb(2, 128, 9);">%Find all reactions that have the old GPR</span></span></div></div><div class="inlineWrapper"><div  class = 'S10'><span style="white-space: normal"><span >    </span><span style="color: rgb(14, 0, 255);">for </span><span >j = 1:length(oldGPRrxns)</span></span></div></div><div class="inlineWrapper"><div  class = 'S10'><span style="white-space: normal"><span >        model = changeGeneAssociation(model, model.rxns{oldGPRrxns(j)}, GPRsReplace{i, 2});</span></span></div></div><div class="inlineWrapper"><div  class = 'S10'><span style="white-space: normal"><span >    </span><span style="color: rgb(14, 0, 255);">end</span></span></div></div><div class="inlineWrapper outputs"><div  class = 'S11'><span style="white-space: normal"><span style="color: rgb(14, 0, 255);">end</span></span></div><div  class = 'S8'><div class="inlineElement eoOutputWrapper embeddedOutputsTextElement" uid="3193EA4F" data-testid="output_51" data-width="420" data-height="18" data-hashorizontaloverflow="false" style="width: 450px; max-height: 261px; white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><div class="textElement" style="white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;">New gene G4 added to model</div></div></div></div></div><h2  class = 'S6'><span>Remove unused genes</span></h2><div  class = 'S1'><span>Let us assume that the reaction PGK has to be removed from the model</span></div><div class="CodeBlock"><div class="inlineWrapper"><div  class = 'S16'><span style="white-space: normal"><span >model = removeRxns(model, </span><span style="color: rgb(170, 4, 249);">'PGK'</span><span >);</span></span></div></div></div><div  class = 'S13'><span>The model now contains genes that do not participate in any GPR</span></div><div class="CodeBlock"><div class="inlineWrapper outputs"><div  class = 'S7'><span style="white-space: normal"><span >find(sum(model.rxnGeneMat, 1) == 0)</span></span></div><div  class = 'S8'><div class='variableElement' style='font-family: Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 12px; '>ans = 3</div></div></div></div><div  class = 'S13'><span>We remove unused genes by re-assigning the model's GPR rules, which updates the reaction-gene-matrix and gene list.</span></div><div  class = 'S1'><span>Store GPR list in a new variable</span></div><div class="CodeBlock"><div class="inlineWrapper"><div  class = 'S16'><span style="white-space: normal"><span >storeGPR = model.grRules;</span></span></div></div></div><div  class = 'S13'><span>Erase model's gene list and reaction-gene-matrix</span></div><div class="CodeBlock"><div class="inlineWrapper"><div  class = 'S9'><span style="white-space: normal"><span >model.rxnGeneMat = [];</span></span></div></div><div class="inlineWrapper"><div  class = 'S15'><span style="white-space: normal"><span >model.genes = [];</span></span></div></div></div><div  class = 'S13'><span>Re-assign GPR rules to model</span></div><div class="CodeBlock"><div class="inlineWrapper"><div  class = 'S9'><span style="white-space: normal"><span style="color: rgb(14, 0, 255);">for </span><span >i = 1 : length(model.rxns)</span></span></div></div><div class="inlineWrapper"><div  class = 'S10'><span style="white-space: normal"><span >    model = changeGeneAssociation(model, model.rxns{i}, storeGPR{i});</span></span></div></div><div class="inlineWrapper outputs"><div  class = 'S11'><span style="white-space: normal"><span style="color: rgb(14, 0, 255);">end</span></span></div><div  class = 'S8'><div class="inlineElement eoOutputWrapper embeddedOutputsTextElement" uid="59B9FB39" data-testid="output_53" data-width="420" data-height="31" data-hashorizontaloverflow="false" style="width: 450px; max-height: 261px; white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><div class="textElement" style="white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;">New gene G1 added to model
New gene G4 added to model</div></div><div class="inlineElement eoOutputWrapper embeddedOutputsTextElement" uid="61EC1A65" data-testid="output_54" data-width="420" data-height="18" data-hashorizontaloverflow="false" style="width: 450px; max-height: 261px; white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><div class="textElement" style="white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;">New gene G2 added to model</div></div></div></div></div><div  class = 'S13'><span>Check that there are no unused genes left in the model</span></div><div class="CodeBlock"><div class="inlineWrapper outputs"><div  class = 'S7'><span style="white-space: normal"><span >find(sum(model.rxnGeneMat, 1) == 0)</span></span></div><div  class = 'S8'><div class="inlineElement eoOutputWrapper embeddedOutputsTextElement" uid="A0D9DB71" data-testid="output_55" data-width="420" data-height="45" data-hashorizontaloverflow="false" style="width: 450px; max-height: 261px; white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><div class="textElement" style="white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;">ans =

  1×0 empty double row vector</div></div></div></div></div><h2  class = 'S6'><span>Remove issues with GPR definitions and spaces in reaction abbreviations</span></h2><div  class = 'S1'><span>Remove issues with quotation marks in the GPR definitions.</span></div><div class="CodeBlock"><div class="inlineWrapper"><div  class = 'S16'><span style="white-space: normal"><span >model.grRules = strrep(model.grRules, </span><span style="color: rgb(170, 4, 249);">''''</span><span >, </span><span style="color: rgb(170, 4, 249);">''</span><span >);</span></span></div></div></div><div  class = 'S13'><span>Remove spaces from reaction abbreviations.</span></div><div class="CodeBlock"><div class="inlineWrapper"><div  class = 'S16'><span style="white-space: normal"><span >model.rxns = strrep(model.rxns, </span><span style="color: rgb(170, 4, 249);">' '</span><span >, </span><span style="color: rgb(170, 4, 249);">''</span><span >);</span></span></div></div></div><div  class = 'S13'><span>Remove unneccessary brackets from the GPR associations. </span></div><div class="CodeBlock"><div class="inlineWrapper"><div  class = 'S9'><span style="white-space: normal"><span style="color: rgb(14, 0, 255);">for </span><span >i = 1 : length(model.grRules)</span></span></div></div><div class="inlineWrapper"><div  class = 'S10'><span style="white-space: normal"><span >    </span><span style="color: rgb(14, 0, 255);">if </span><span >isempty(strfind(model.grRules{i}, </span><span style="color: rgb(170, 4, 249);">'and'</span><span >)) &amp;&amp; isempty(strfind(model.grRules{i}, </span><span style="color: rgb(170, 4, 249);">'or'</span><span >))</span><span style="color: rgb(2, 128, 9);">% no AND or OR in GPR</span></span></div></div><div class="inlineWrapper"><div  class = 'S10'><span style="white-space: normal"><span >        model.grRules{i} = regexprep(model.grRules{i}, </span><span style="color: rgb(170, 4, 249);">'[\(\)]'</span><span >, </span><span style="color: rgb(170, 4, 249);">''</span><span >);</span></span></div></div><div class="inlineWrapper"><div  class = 'S10'><span style="white-space: normal"><span >    </span><span style="color: rgb(14, 0, 255);">end</span></span></div></div><div class="inlineWrapper"><div  class = 'S15'><span style="white-space: normal"><span style="color: rgb(14, 0, 255);">end</span></span></div></div></div><h2  class = 'S6'><span>Extract subnetwork</span></h2><div  class = 'S1'><span>Extract a subnetwork from the model consisting of the reactions HEX1, PGI, FBP, and FBA. The function will remove unused metabolites.</span></div><div class="CodeBlock"><div class="inlineWrapper outputs"><div  class = 'S7'><span style="white-space: normal"><span >rxnList = {</span><span style="color: rgb(170, 4, 249);">'HEX1'</span><span >; </span><span style="color: rgb(170, 4, 249);">'PGI'</span><span >; </span><span style="color: rgb(170, 4, 249);">'FBP'</span><span >; </span><span style="color: rgb(170, 4, 249);">'FBA'</span><span >}</span></span></div><div  class = 'S8'><div class="inlineElement eoOutputWrapper embeddedOutputsVariableStringElement" uid="59BDDC0C" data-testid="output_56" data-width="420" data-height="76" data-hashorizontaloverflow="false" style="width: 450px; max-height: 261px; white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><div class="textElement" style="white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><div style="white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><span class="variableNameElement" style="white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;">rxnList = </span></div><div style="white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;">    'HEX1'
    'PGI'
    'FBP'
    'FBA'
</div></div></div></div></div><div class="inlineWrapper outputs"><div  class = 'S12'><span style="white-space: normal"><span >subModel = extractSubNetwork(model, rxnList)</span></span></div><div  class = 'S8'><div class="inlineElement eoOutputWrapper embeddedOutputsVariableStringElement scrollableOutput" uid="344B96BB" data-testid="output_57" data-width="420" data-height="258" data-hashorizontaloverflow="true" style="width: 450px; max-height: 269px; white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><div class="textElement" style="white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><div style="white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;"><span class="variableNameElement" style="white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;">subModel = </span></div><div style="white-space: normal; font-style: normal; color: rgb(64, 64, 64); font-size: 12px;">          rxns: {4×1 cell}
             S: [11×4 double]
            lb: [4×1 double]
            ub: [4×1 double]
             c: [4×1 double]
          mets: {11×1 cell}
             b: [11×1 double]
         rules: {4×1 cell}
         genes: {3×1 cell}
        osense: -1
        csense: [11×1 char]
    rxnGeneMat: [4×3 double]
      rxnNames: {4×1 cell}
    subSystems: {4×1 cell}
      metNames: {11×1 cell}
       grRules: {4×1 cell}
          note: 'EX_glc_D[c] andEX_glc_D[e]are set to have a ratio of1:2.'
</div></div></div></div></div></div><h2  class = 'S6'><span>REFERENCES</span></h2><div  class = 'S1'><span>[1] Orth, J. D., Thiele I., and Palsson, B. Ø. What is flux balance analysis? </span><span style=' font-style: italic;'>Nat. Biotechnol., </span><span>28(3), 245-248 (2010).</span></div><div  class = 'S1'><span>[2] Feist, A. M., Palsson, B. Ø. The growing scope of applications of genome-scale metabolic reconstructions: the case of </span><span style=' font-style: italic;'>E. coli</span><span>. </span><span style=' font-style: italic;'>Nature Biotechnology, </span><span>26(6), 659-667 (2008).</span></div><div  class = 'S1'><span>[3] Feist, A. M., Palsson, B. Ø. The Biomass Objective Function. </span><span style=' font-style: italic;'>Current Opinion in Microbiology, </span><span>13(3), 344-349 (2010).</span></div>
<br>
<!-- 
##### SOURCE BEGIN #####
%% Model manipulation
% *Author(s): Vanja Vlasov, Systems Biochemistry Group, LCSB, University of 
% Luxembourg,*
% 
% *Thomas Pfau,  Systems Biology Group, LSRU, University of Luxembourg.*
% 
% *Reviewer(s): Ines Thiele, Systems Biochemistry Group, LCSB, University of 
% Luxembourg.* 
% 
% *Catherine Clancy, Systems Biochemistry Group, LCSB, University of Luxembourg.*
% 
% *Stefania Magnusdottir, Molecular Systems Physiology Group, LCSB, University 
% of Luxembourg.*
%% INTRODUCTION
% In this tutorial, we will do a manipulation with a simple model of the first 
% few reactions of the glycolysis metabolic pathway as created in the "Model Creation" 
% tutorial.
% 
% Glycolysis is the metabolic pathway that occurs in most organisms in the cytosol 
% of the cell. First, we will use the beginning of that pathway to create a simple 
% constraint-based metabolic network (Figure 1).
% 
% 
% 
% Figure 1: A small metabolic network consisting of the seven reactions in the 
% glycolysis pathway. 
% 
% At the beginning of the reconstruction, the initial step is to assess the 
% integrity of the draft reconstruction. Furthermore, an evaluation of accuracy 
% is needed: check necessity of each reaction and metabolite,  the accuracy of 
% the stoichiometry, and direction and reversibility of the reactions.
% 
% The metabolites structures and reactions are from the Virtual Metabolic Human 
% database (VMH, <http://vmh.life/ http://vmh.life>).
% 
% After creating or loading the model and to simulate different model conditions, 
% the model can be modified, such as:
%% 
% * Creating, adding and handling reactions;
% * Adding exchange, sink and demand reactions;
% * Altering reaction bounds;
% * Altering reactions;
% * Removing reactions and metabolites;
% * Searching for duplicates and comparison of two models;
% * Changing the model objective;
% * Changing the direction of reaction(s);
% * Creating gene-reaction-associations ('GPRs');
% * Extracting a subnetwork
%% EQUIPMENT SETUP
% Start CobraToolbox

initCobraToolbox(false) % false, as we don't want to update;
%% PROCEDURE
%% Generate a network
% A constraint-based metabolic model contains the stoichiometric matrix ($$S$) 
% with reactions and metabolites [1].
% 
% $$S$ is a stoichiometric representation of metabolic networks corresponding 
% to the reactions in the biochemical pathway. In each column of the $$S$ is a 
% biochemical reaction ($$n$) and in each row is a precise metabolite ($$m$). 
% There is a stoichiometric coefficient of zero, which means that metabolite does 
% not participate in that distinct reaction. The coefficient also can be positive 
% when the appropriate metabolite is produced, or negative for every metabolite 
% consumed [1].
% 
% 
% 
% Generate a model using the |createModel()| function:

ReactionFormulas = {'glc_D[e]  -> glc_D[c]',...
    'glc_D[c] + atp[c]  -> h[c] + adp[c] + g6p[c]',...
    'g6p[c]  <=> f6p[c]',...
    'atp[c] + f6p[c]  -> h[c] + adp[c] + fdp[c]',...
    'fdp[c] + h2o[c]  -> f6p[c] + pi[c]',...
    'fdp[c]  -> g3p[c] + dhap[c]',...
    'dhap[c]  -> g3p[c]'};
ReactionNames = {'GLCt1r', 'HEX1', 'PGI', 'PFK', 'FBP', 'FBA', 'TPI'};
lowerbounds = [-20, 0, -20, 0, 0, -20, -20];
upperbounds = [20, 20, 20, 20, 20, 20, 20];
model = createModel(ReactionNames, ReactionNames, ReactionFormulas,...
                   'lowerBoundList', lowerbounds, 'upperBoundList', upperbounds);
%% 
% We can now have a look at the different model fields created. The stoichiometry 
% is stored in the $$S$ field of the model, which was described above. Since this 
% is commonly a sparse matrix (i.e. it contains a lot of zeros), it may be useful 
% for your understanding to display the full representation:

full(model.S)
%% 
% It is required for a model to consist of the descriptive fields: |model.mets| 
% and |model.rxns,| which represent the metabolites and the reactions respectively. 

model.mets
model.rxns
%% 
% The fields in a COBRA model are commonly column vectors, which is important 
% to note when writing functions manipulating these fields.
% 
% There are a few more fields present in each COBRA model:
% 
% |model.lb|, indicating the lower bounds of each reaction, and |model.ub| indicating 
% the upper bound of a reaction.  

% this displays an array with reaction names and flux bounds.
[{'Reaction ID', 'Lower Bound', 'Upper Bound'};...   
 model.rxns, num2cell(model.lb), num2cell(model.ub)]
% This is a convenience function which does pretty much the same as the line above.
printFluxBounds(model);
%% 
% Before we start to modify the model, it might be useful to store in the workspace 
% some of the current properties of the model:

mets_length = length(model.mets)
rxns_length = length(model.rxns)
%% Creating, adding and handling reactions
% If we want to add a reaction to the model or modify an existing reaction use 
% the function |addReaction|. 
% 
% We will add to the model some more reactions from glycolysis. There are two 
% different approaches to adding reactions to a model:
%% 
% # The formula approach
% # The list appraoch
%% 
% *The formula approach*

model = addReaction(model, 'GAPDH',...
       'reactionFormula', 'g3p[c] + nad[c] + 2 pi[c] -> nadh[c] + h[c] + 13bpg[c]');
model = addReaction(model, 'PGK',...
       'reactionFormula', '13bpg[c] + adp[c] -> atp[c] + 3pg[c]');
model = addReaction(model, 'PGM', 'reactionFormula', '3pg[c] <=> 2pg[c]' );
%% 
% Display the stoichiometric matrix after adding reactions (note the enlarge 
% link when you move your mouse over the output to display the full matrix):

full(model.S) 
%% 
% * one extra column is added (for added reaction) and 5 new rows (for nadh, 
% nad, 13bpg, 2pg and 3pg metabolites)
%% 
% If you want to search for the indecies of reactions in the model, and change 
% the order of the select reactions, use the following functions:

rxnID = findRxnIDs(model, model.rxns)
model.rxns
model = moveRxn(model, 8, 1);
model.rxns
%% 
% While the function |moveRxn| does not modify the network structure it can 
% be useful in keeping a model tidy.
%% 
% *The list approach*

model = addReaction(model, 'GAPDH2',...
    'metaboliteList', {'g3p[c]', 'nad[c]', 'pi[c]', '13bpg[c]', 'nadh[c]', 'h[c]' },...
    'stoichCoeffList', [-1; -1; -2; 1; 1; 1], 'reversible', false);
%% 
% * The |addReaction| function has the ability to recognize duplicate reactions. 
% No reaction added here since the reaction is recognised to already exist in 
% the model. 
%% 
% Since the fourth reaction we attempted to add to the model was a duplicate, 
% the number of the reactions in the model should only of increased by three and 
% the number of metabolites in the model should of only increaed by five (13bpg, 
% nad, nadh, 23bpg and 2pg).

assert(length(model.rxns) == rxns_length + 3)
assert(length(model.mets) == mets_length + 5) 
%% Adding exchange, sink and demand reactions
% The are three specific types of reactions in a COBRA model that use and recycle 
% accumulated metabolites, or produce the required metabolites:
%% 
% # _Exchange reactions_ - are reactions that move metabolites across _in silico_ 
% compartments. These _in silico_ compartments are representive of intra- and 
% inter- cellular membranes.
% # _Sink reactions_ - The metabolites, produced in reactions that are outside 
% of an ambit of the system or in unknown reactions, are supplied to the network 
% with reversible sink reactions.
% # _Demand reactions_ - Irreversible reactions added to the model to consume 
% metabolites that are deposited in the system.
%% 
% There are two ways to implement these type of reactions:
%% 
% # *Use the |addReaction| function, detailing the stoichiometric coefficient:*

model = addReaction(model, 'EX_glc_D[e]', 'metaboliteList', {'glc_D[e]'} ,...
                    'stoichCoeffList', [-1]);
%% 
% To find exchange reactions in the model use the |findExcRxns| function:

% determines whether a reaction is a general exchange reaction and
% whether its an uptake.
[selExc, selUpt] = findExcRxns(model, 0, 1)
%% 
% *2.  Use a utility function to create the specific type of reaction: |addExchangeRxn|, 
% |addSinkReactions|, |addDemandReaction|.*

model = addExchangeRxn(model, {'glc_D[e]', 'glc_D[c]'})
%% 
% 

model = addSinkReactions(model, {'13bpg[c]', 'nad[c]'})
%% 
% 

 model = addDemandReaction(model, {'dhap[c]', 'g3p[c]'})
%% Setting a ratio between the reactions
% It is important to emphasise that previous knowledge base information should 
% be taken into account when generating a model. If this information is omited, 
% the analysis of a model could be adversely altered and consequent results not 
% representative of the network. 
% 
% For instance, if it is known that the flux of one reaction is _X_ times the 
% flux of another reaction, it is recommended to 'couple' (i.e., set a ratio) 
% the reactions in the model. 
% 
% E.g. $1\text{ }v\text{ }\text{EX}_\text{glc}_D\left\lbrack c\right\rbrack 
% =2\text{ }v\text{ }\text{EX}_\text{glc}_D\left\lbrack e\right\rbrack$

model = addRatioReaction (model, {'EX_glc_D[c]', 'EX_glc_D[e]'}, [1; 2])
%% *Constraining the flux boundaries of a reaction*
% In order to respect the transport and exchange potential of a particular metabolite, 
% or to resemble the different conditions in the model, we frequently need to 
% set appropriate limits of the reactions.

model = changeRxnBounds(model, 'EX_glc_D[e]', -18.5, 'l');
%% Modifying reactions
% The |addReaction| function is also a good choice to modify reactions. By supplying 
% to the function a new stoichiometry, the old will be overwritten. 
% 
% For example, further up, we added the wrong stoichiometry for the GAP-Dehydrogenase 
% with a coefficient of 2 for phosphate. Print the reaction to visulize:

printRxnFormula(model, 'rxnAbbrList', 'GAPDH');
%% 
% Correct the reaction using |addReaction:| with the corrected stoichiometry:

model = addReaction(model, 'GAPDH',...
    'metaboliteList', {'g3p[c]', 'nad[c]', 'pi[c]', '13bpg[c]', 'nadh[c]','h[c]' },...
    'stoichCoeffList', [-1; -1; -1; 1; 1; 1]);
%% 
% 
% 
% We can add a gene rule to the reaction using the |changeGeneAssociation| function: 

model = changeGeneAssociation(model, 'GAPDH', 'G1 and G2');
printRxnFormula(model, 'rxnAbbrList', {'GAPDH'}, 'gprFlag', true);
%% 
% Alternatively, one can add a gene rule to a reaction using the |addReaction| 
% function, and within this function applying the |geneRule| input option. 

model = addReaction(model, 'PGK', 'geneRule', 'G2 or G3', 'printLevel', 0);
printRxnFormula(model, 'gprFlag', true);
%% Remove reactions and metabolites
% To delete reactions from the model, use the |removeRxns| function:

 model = removeRxns(model, {'EX_glc_D[c]', 'EX_glc_D[e]', 'sink_13bpg[c]', ...
                             'sink_nad[c]', 'DM_dhap[c]', 'DM_g3p[c]'});

 assert(rxns_length + 3 == length(model.rxns));
%% 
% * The reaction length was updated since a number of reactions were removed 
% from the model. 
%% 
% To remove metabolites from the model, use the |removeMetabolites()| function:

  model = removeMetabolites(model, {'3pg[c]', '2pg[c]'}, false);
  printRxnFormula(model, 'rxnAbbrList', {'GAPDH'}, 'gprFlag', true);
%% 
% * The '|GAPDH|' reaction is still present in the model since there are other 
% metabolites in the reaction, not just the metabolites we tried to delete. The 
% 'false' input option of the |removeMetabolites| function indictes that only 
% empty reactions should be removed.
%% 
% To delete metabolites and reactions with zero rows and columns, the |removeTrivialStoichiometry()| 
% function can be used:

  model = removeTrivialStoichiometry(model)
%% Search for duplicate reactions and comparison of two models
% Since genome-scale metabolic models are expanding every day [2], the need 
% to compare models is also growing. The elementary functions in The Cobra Toolbox 
% can support simultaneous structural analysis and comparison.
% 
% Checking for reaction duplicates with the |checkDuplicateRxn()| function (i.e. 
% by reaction abbreviation), using either the method: 
%% 
% * '|S|' (does not detect reverse reactions), or 
% * '|FR|' (neglects reactions direction).
%% 
% For demonstration of the S method, first check for dupicates and then add 
% the duplicate reaction to the model:

[model, removedRxn, rxnRelationship] = checkDuplicateRxn(model, 'S', 1, 1);
printRxnFormula(model, 'rxnAbbrList', {'GLCt1r'});
model = addReaction(model, 'GLCt1r_duplicate_reverse',...
                    'metaboliteList', {'glc_D[e]', 'glc_D[c]'},...
                    'stoichCoeffList', [1 -1], 'lowerBound', 0, ...
                    'upperBound', 20, 'checkDuplicate', 0);
%% 
% Detecting duplicates using the S method:

method = 'S'; 
[model,removedRxn, rxnRelationship] = checkDuplicateRxn(model, method, 1, 1);
%% 
% * The GLCt1r_duplicate_reverse reaction is not detected as a duplicate reaction 
% therefore will not be removed as the S method does not detect a reverse reactions.
% * Reevaluate the reaction length to show this:

assert(rxns_length + 3 == length(model.rxns));
%% 
% Detecting duplicates using the FR method:

method = 'FR';
[model, removedRxn, rxnRelationship] = checkDuplicateRxn(model, method, 1, 1)
assert(rxns_length + 2 == length(model.rxns))
%% 
% * The GLCt1r_duplicate_reverse reaction is detected as a duplicate reaction 
% therefore will not be removed as the FR method does detect a reverse reactions.
%% 
% Checking for non-unique reactions and metabolites in a model using the |checkCobraModelUnique()| 
% function: 

model = checkCobraModelUnique(model, false)
%% 
% * Input option 'false' means the function will not renames non-unique reaction 
% names and metabolites
%% Changing the model's objective
% Simulating specific objectives of a model is often necessary in order to perform 
% an investigation of different conditions. One of the fundamental objectives 
% is optimal growth [3]. The model can be modified to get different conditions 
% by changing the model objective.
% 
% One reaction is set as the objective, and has an objective coefficient of 
% 0.5:

modelNew = changeObjective(model, 'GLCt1r', 0.5);
%% 
% Multiple reactions are set collectively as the objective, and the default 
% objective coefficient of 1 for each reaction:

modelNew = changeObjective(model, {'PGI'; 'PFK'; 'FBP'});
%% The direction of reactions 
% Sometimes it may be important to have all reactions in a model as irreversible 
% reactions (i.e. only allow a forward reaction / positive flux in reactions). 
% This can be important if, for example, the absolute flux values are of interest, 
% and negative flux would reduce an objective while it should actually increase 
% it. The COBRA Toolbox offers functionality to change all reactions in a model 
% to an irreversible format. IT does this by splitting all reversible reactions 
% and adjusting the respective lower and upper bounds, such that the model capacities 
% stay the same. 
% 
% Let us see, how the glycolysis model currently looks:

printRxnFormula(model);
%% 
% To convert a model to an irreversible model use the _convertToIrreversible_ 
% command:

[modelIrrev, matchRev, rev2irrev, irrev2rev] = convertToIrreversible(model);
%% 
% Compare the irreversible model with the original model:

printRxnFormula(modelIrrev);
%% 
% * You will notice, that there are more reactions in this model and that all 
% reactions which have a lower bound < 0 are split in two. 
%% 
% There is also a function to convert an irreversible model to a reversible 
% model:

modelRev = convertToReversible(modelIrrev);
%% 
% If we now compare the reactions of this model with those from the original 
% model, they should look the same.

printRxnFormula(modelRev);
%% Create gene-reaction-associations (GPRs) from scratch.
% Assign the GPR '(G1) or (G2)' to the reaction HEX1

model = changeGeneAssociation(model, 'HEX1', '(G1) or (G2)');
%% Replace an existing GPRs with a new one. 
% Here, we will search for all instances of a specific GPR ('G1 and G2 ') and 
% replace it with a new one ('G1 or G4').
% 
% Define the old and the new GPRs. 

GPRsReplace = {'G1 and G2'	'G1 or G4'};
for  i = 1 : size(GPRsReplace, 1)
    oldGPRrxns = find(strcmp(model.grRules, GPRsReplace{i, 1}));%Find all reactions that have the old GPR
    for j = 1:length(oldGPRrxns)
        model = changeGeneAssociation(model, model.rxns{oldGPRrxns(j)}, GPRsReplace{i, 2});
    end
end
%% Remove unused genes
% Let us assume that the reaction PGK has to be removed from the model

model = removeRxns(model, 'PGK');
%% 
% The model now contains genes that do not participate in any GPR

find(sum(model.rxnGeneMat, 1) == 0)
%% 
% We remove unused genes by re-assigning the model's GPR rules, which updates 
% the reaction-gene-matrix and gene list.
% 
% Store GPR list in a new variable

storeGPR = model.grRules;
%% 
% Erase model's gene list and reaction-gene-matrix

model.rxnGeneMat = [];
model.genes = [];
%% 
% Re-assign GPR rules to model

for i = 1 : length(model.rxns)
    model = changeGeneAssociation(model, model.rxns{i}, storeGPR{i});
end
%% 
% Check that there are no unused genes left in the model

find(sum(model.rxnGeneMat, 1) == 0)
%% Remove issues with GPR definitions and spaces in reaction abbreviations
% Remove issues with quotation marks in the GPR definitions.

model.grRules = strrep(model.grRules, '''', '');
%% 
% Remove spaces from reaction abbreviations.

model.rxns = strrep(model.rxns, ' ', '');
%% 
% Remove unneccessary brackets from the GPR associations. 

for i = 1 : length(model.grRules)
    if isempty(strfind(model.grRules{i}, 'and')) && isempty(strfind(model.grRules{i}, 'or'))% no AND or OR in GPR
        model.grRules{i} = regexprep(model.grRules{i}, '[\(\)]', '');
    end
end
%% Extract subnetwork
% Extract a subnetwork from the model consisting of the reactions HEX1, PGI, 
% FBP, and FBA. The function will remove unused metabolites.

rxnList = {'HEX1'; 'PGI'; 'FBP'; 'FBA'}
subModel = extractSubNetwork(model, rxnList)
%% REFERENCES
% [1] Orth, J. D., Thiele I., and Palsson, B. Ø. What is flux balance analysis? 
% _Nat. Biotechnol.,_ 28(3), 245-248 (2010).
% 
% [2] Feist, A. M., Palsson, B. Ø. The growing scope of applications of genome-scale 
% metabolic reconstructions: the case of _E. coli_. _Nature Biotechnology,_ 26(6), 
% 659-667 (2008).
% 
% [3] Feist, A. M., Palsson, B. Ø. The Biomass Objective Function. _Current 
% Opinion in Microbiology,_ 13(3), 344-349 (2010).
##### SOURCE END #####
-->
</div></body></html>